Hi all,
I'm trying to efficiently pull data out of an xml file into a XmlDocument
AND create another "sub" document based on one subtree of the document. For
example, say I've got:
<Books>
<Book>
<Title>Some book</Title>
</Book>
<Book>
<Title>Some other book</Title>
</Book>
<Books>
So far I've tried things like:
XmlDocument doc = new XmlDocument();
doc.LoadXml("Books>" +
"<Book><title>Some book</title></Book>" +
"<Book><title>Some other book</title></Book>"+
"</Books>");
XmlNode nodBook= doc.FirstChild.FirstChild;
XmlDocument docPart = new XmlDocument();
docPart.ImportNode( nodBook, true );
However, docPart only winds up as null. I've tried variations on the
ImportNode theme and received errors relating to the context being wrong for
the node.
Any pointers on create a sub-XmlDocument from an existing XmlDocument?
Thanks,
John
|