System.Xml.XmlReader.ReadElementContentAsObject Method

Reads the current element and returns the contents as an object.

Syntax

public virtual object ReadElementContentAsObject ()

Returns

A boxed common language runtime (CLR) object of the most appropriate type. The XmlReader.ValueType property determines the appropriate CLR type. If the content is typed as a list type, this method returns an array of boxed objects of the appropriate type.

Remarks

This method reads the start tag, the contents of the element, and moves the reader past the end element tag. It expands entities and ignores processing instructions and comments. The element can only contain simple content. That is, it cannot have child elements.

For more information, see Reading Typed Data and the tp://go.microsoft.com/fwlink/?LinkId=4871 recommendation.

For the asynchronous version of this method, see XmlReader.ReadElementContentAsObjectAsync.

Requirements

Namespace: System.Xml
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0