XmlObjectSerializer.IsStartObject Method

Definition

Gets a value that specifies whether the serializer can read the object.

Overloads

IsStartObject(XmlDictionaryReader)

Gets a value that specifies whether the XmlDictionaryReader is positioned over an XML element that can be read.

IsStartObject(XmlReader)

Gets a value that specifies whether the XmlReader is positioned over an XML element that can be read.

Remarks

This method checks whether the reader is positioned on an element to read, and returns true if the element is the top-level element for the object found in the XML stream or document. To return true, the found element must have an expected name. The actual expected element name depends on the implementation of the serializer.

With the DataContractSerializer, the starting element is specified in the constructor of the extension class. For an example, see the constructors for the DataContractSerializer class.

IsStartObject(XmlDictionaryReader)

Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs

Gets a value that specifies whether the XmlDictionaryReader is positioned over an XML element that can be read.

C#
public abstract bool IsStartObject(System.Xml.XmlDictionaryReader reader);

Parameters

reader
XmlDictionaryReader

An XmlDictionaryReader used to read the XML stream or document.

Returns

true if the reader can read the data; otherwise, false.

Remarks

This method checks if the reader is positioned on an element to read, and returns true if the element is the top-level element for the object found in the XML stream or document. The XmlObjectSerializer implementation determines when to return true. Implementations may check that they are positioned on an element or look for an expected element name. One implementation of the XmlObjectSerializer, the DataContractSerializer, checks that it is positioned on an element and also checks that the element name is the top level expected name for the type currently being deserialized.

If needed, additional attributes in the XML stream can be read while positioned on the top level element before reading XML contents using the ReadObject method.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

IsStartObject(XmlReader)

Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs

Gets a value that specifies whether the XmlReader is positioned over an XML element that can be read.

C#
public virtual bool IsStartObject(System.Xml.XmlReader reader);

Parameters

reader
XmlReader

An XmlReader used to read the XML stream or document.

Returns

true if the reader is positioned over the starting element; otherwise, false.

Remarks

This method checks whether the reader is positioned on an element to read, and returns true if the element is the top-level element for the object found in the XML stream or document. To return true, the found element must have an expected name. The actual expected element name depends on the implementation of the serializer.

With the DataContractSerializer, the starting element is specified in the constructor of the extension class. For an example, see the constructors for the DataContractSerializer class.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0