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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access