简体   繁体   中英

Get data for XmlDocument in C#

I want to read entire data/all nodes from XmlDocument. I don't want to use InnerXml/OuterXml properties. Any other way to read from XmlDocument ?. Below example I have get data using OuterXml property, but I don't want to use Outerxml.

Ex:

     XmlDocument ACTGraphicalXMLDoc = new XmlDocument();
     ACTGraphicalXMLDoc.LoadXml(ACTConfigXML);

     StringBuilder ConfigXML = new StringBuilder();
     ConfigXML.Append(ACTGraphicalXMLDoc.OuterXml);
     string ConfigXML2 = ConfigXML.ToString();

You can try the following:

StringWriter sw = new StringWriter();
XmlTextWriter tx = new XmlTextWriter(sw);
ACTGraphicalXMLDoc.WriteTo(tx);
sw.ToString();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM