O'Reilly logo

Microsoft® .NET Compact Framework Kick Start by Ronnie Yates, Erik Rubin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Accessing Markup from Nodes

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.

Listing 11.10.
 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); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required