Xml Reader - Read Entire Subtree
-
Hi guys, I am working on a program which reads and writes XML for plugin objects. In some instances a plugin might not be available, for example if a document is loaded on a computer which does not have the plugin installed. So to remedee this situation I am writing a class which will store all of the origionally read XML and then later restore that XML to the document. Is there a simple way to read an entire XML subtree (of a particular XML element) into a string using an object of the XmlReader class? This would be fantastic because this would solve my problem instantly. From past work I seem to remember something about writing raw XML into a file, however I cannot find anything about reading an entire subtree as a string in MSDN. Any help would be fantastic! Best regards! Lea Hayes
-
Hi guys, I am working on a program which reads and writes XML for plugin objects. In some instances a plugin might not be available, for example if a document is loaded on a computer which does not have the plugin installed. So to remedee this situation I am writing a class which will store all of the origionally read XML and then later restore that XML to the document. Is there a simple way to read an entire XML subtree (of a particular XML element) into a string using an object of the XmlReader class? This would be fantastic because this would solve my problem instantly. From past work I seem to remember something about writing raw XML into a file, however I cannot find anything about reading an entire subtree as a string in MSDN. Any help would be fantastic! Best regards! Lea Hayes
lhayes00 wrote:
Is there a simple way to read an entire XML subtree (of a particular XML element) into a string using an object of the XmlReader class?
Why not go with
XMLDocument
class and use XPath to get the element and child elements. Look at the "innerXML" property to get a string representation of the entire element. -
lhayes00 wrote:
Is there a simple way to read an entire XML subtree (of a particular XML element) into a string using an object of the XmlReader class?
Why not go with
XMLDocument
class and use XPath to get the element and child elements. Look at the "innerXML" property to get a string representation of the entire element.