I created an XmlDocument from a string and get the first node using FirstChild.
dim newPipeline as new XmlDocument(pipeline)
dim nn as XMlNode = newPipeline.FirstChild
however in the debugger nn appears to be an XmlElement.
What is the difference?
[quote=30296:@Brian O’Brien]however in the debugger nn appears to be an XmlElement.
What is the difference? [/quote]
XmlNode is used for polymorphism. There’s several subclasses of XmlNode and the returned results can contain any of them. For XmlElement specifically, it appears to add attribute information to XmlNode.
The reason I’m asking is because later on in the code:
f = new FolderItem(configFilePath, FolderItem.PathTypeShell)
which generates an xmlException… and I’m not sure why.
I think the problem your’e having is the magic tether between XmlNode and the XmlDocument it’s associated with.
You can’t treat XmlDocument like a freeform tree, the nodes are bound to their root and moving them to a different tree is a no no. I don’t build Xml very often, at least with the built in nodes, so I don’t remember all the limitations or what can be done to move them.
I figured out the tether by finally making sense of why CreateElement is used. It ties the node to the XmlDocument that created it…
[code]dim doc As new XmlDocument
doc.AppendChild( new XmlElement ) //wrong
doc.AppendChild( doc.CreateElement(“foo”) ) //allowed[/code]
I usually just parse and explore the tree, for building or manipulating I use my own (funky, simple) classes that are freeform so I don’t have to both with the tether. Hopefully someone can respond who knows how to move nodes between trees. afaik you’ll need to rebuild the NewNode (nn) with the XmlDocument you want to place it in.
The XMLDocument class has an ImportNode method that can take a node from another XMLDocument and copy it into itself.