August 2003
Beginner to intermediate
600 pages
12h 57m
English
There may be times when you need to access an element's contents in markup form. The XmlNode class provides two properties for retrieving a node's XML markup content: OuterXml and InnerXml. OuterXml returns the content of the current node, with the current node as the root element. The InnerXml property returns only the content of the current element. The XML returned from InnerXml should be considered an XML fragment. Listing 11.10 shows how to use OuterXml and InnerXml to display the markup content of the node.
C# XmlDocument doc = new XmlDocument(); Doc.LoadXml("<Book>" + "<Title>Catcher in the Rye</Title>" + "<Price>25.98</Price>" + "</Book>"); MessageBox.Show("OuterXml:" + doc.DocumentElement.OuterXml); ... |
Read now
Unlock full access