public MoveToContent ( ) : System.Xml.XmlNodeType | ||
return | System.Xml.XmlNodeType |
XmlReader reader = XmlReader.Create("myXmlFile.xml"); reader.MoveToContent(); // This will move the reader to the first content node of the XML file
XmlReader reader = XmlReader.Create("myXmlFile.xml"); while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { reader.MoveToContent(); // This skips any non-content elements (such as whitespace) and moves the reader to the first content node of the current element string content = reader.ReadInnerXml(); // This reads the content of the current element // Do something with the content... } }These code examples use the System.Xml package library in C#. The XmlReader class is used to read XML data and the MoveToContent method is used to skip past any non-content elements.