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 Text from Elements

When working with an XmlDocument and its child elements, you may need to retrieve text data from between the start and end tags of an element. Using the XmlTextReader, you can call ReadElementString or ReadString to get text with an element. With the XmlElement object you have two options, as well. The easiest way to get the text content of an element is to use the InnerText property, which returns the concatenated text values of the node and all its child nodes. For example, calling InnerText on the DocumentElement of an XmlDocument loaded with <root>first<child>,second</child>,last</root> will return the string first,second,last. This method can also be used to set the InnerText of the current node. It is very important ...

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