ReadElementString()

XmlReader::ReadElementString() method

Reads a text-only element. However, it is recommended to use the XmlReader::ReadElementContentAsString method instead, because it provides a more straightforward way to handle this operation.

virtual String System::Xml::XmlReader::ReadElementString()

Return Value

The text contained in the element that was read. An empty string if the element is empty.

Exceptions

ExceptionDescription
XmlExceptionThe next content node is not a start tag; or the element found does not contain a simple text value.

XmlReader::ReadElementString(String) method

Checks that the XmlReader::get_Name value of the element found matches the given string before reading a text-only element. However, it is recommended to use the XmlReader::ReadElementContentAsString method instead, because it provides a more straightforward way to handle this operation.

virtual String System::Xml::XmlReader::ReadElementString(String name)

Arguments

ParameterTypeDescription
nameStringThe name to check.

Return Value

The text contained in the element that was read. An empty string if the element is empty.

Exceptions

ExceptionDescription
XmlExceptionIf the next content node is not a start tag; if the element Name does not match the given argument; or if the element found does not contain a simple text value.

XmlReader::ReadElementString(String, String) method

Checks that the XmlReader::get_LocalName and XmlReader::get_NamespaceURI values of the element found matches the given strings before reading a text-only element. However, it is recommended to use the XmlReader::ReadElementContentAsString method instead, because it provides a more straightforward way to handle this operation.

virtual String System::Xml::XmlReader::ReadElementString(String localname, String ns)

Arguments

ParameterTypeDescription
localnameStringThe local name to check.
nsStringThe namespace URI to check.

Return Value

The text contained in the element that was read. An empty string if the element is empty.

Exceptions

ExceptionDescription
XmlExceptionIf the next content node is not a start tag; if the element LocalName or NamespaceURI values do not match the given arguments; or if the element found does not contain a simple text value.

See Also