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 ...

Get Microsoft® .NET Compact Framework Kick Start now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.