XmlReader::Value Property
When overridden in a derived class, gets the text value of the current node.
Assembly: System.Xml (in System.Xml.dll)
Property Value
Type: System::String^The value returned depends on the NodeType of the node. The following table lists node types that have a value to return. All other node types return String.Empty.
Node type | Value |
|---|---|
Attribute | The value of the attribute. |
CDATA | The content of the CDATA section. |
Comment | The content of the comment. |
DocumentType | The internal subset. |
ProcessingInstruction | The entire content, excluding the target. |
SignificantWhitespace | The white space between markup in a mixed content model. |
Text | The content of the text node. |
Whitespace | The white space between markup. |
XmlDeclaration | The content of the declaration. |
| Exception | Condition |
|---|---|
| InvalidOperationException | An XmlReader method was called before a previous asynchronous operation finished. In this case, InvalidOperationException is thrown with the message “An asynchronous operation is already in progress.” |
For the asynchronous version of this property, see the GetValueAsync method.
The following example reads an XML file and displays each of the nodes.
The sample uses the items.xml file.
<?xml version="1.0"?> <!-- This is a sample XML document --> <!DOCTYPE Items [<!ENTITY number "123">]> <Items> <Item>Test with an entity: &number;</Item> <Item>Test with a child element <more/> stuff</Item> <Item>Test with a CDATA section <![CDATA[<456>]]> def</Item> <Item>Test with a char entity: A</Item> <!-- Fourteen chars in this element.--> <Item>1234567890ABCD</Item> </Items>
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1