Reads a text-only element.
[Visual Basic] Overloads Public Function ReadString() As String [C#] public string ReadString(); [C++] public: String* ReadString(); [JScript] public function ReadString() : String;
The text contained in the element that was read. If the element was empty (i.e. of the form
Exceptions
Exception Type | Condition |
---|---|
XmlException | If the input is not of the form |
This method reads an element that contains text only. The method is implemented as follows:
The method first reads a start tag (possibly skipping whitespace, comments, and processing instructions that precede the start tag), then reads a text node, and finally reads an end tag. An exception is thrown if the input is not in one of the following forms:
Following a call to this method, the reader is positioned on the node following the end tag of the element that was read.
Example
Given the following XML input:
and given an XmlTextReader that is positioned on the
To read an optional element, a call to
IsStartTag can be combined with a call to ReadString, as is the case for the line that reads the
See Also
XmlReader Class | XmlReader Members | System.Xml Namespace | XmlReader.ReadString Overload List | ReadString | ReadString | ReadString