public abstract class XmlReader
Object
XmlReader
System.Xml
XML
Represents a reader that provides non-cached, forward-only access to XML data.
This class provides forward-only, read-only access to a stream of XML data. This class enforces the rules of well-formed XML but does not perform data validation.This class conforms to the W3C Extensible Markup Language (XML) 1.0 and the Namespaces in XML recommendations.
A given set of XML data is modeled as a tree of nodes. The different types of nodes are specified in the XmlNodeType enumeration. The reader is advanced to the next node using the System.Xml.XmlReader.Read method. The current node refers to the node on which the reader is positioned. The following table lists the node properties exposed for the current node.
This class does not expand default attributes or general entities. Any general entities encountered are returned as a single empty
Property Description AttributeCount The number of attributes on the node. BaseUri The base URI of the node. Depth The depth of the node in the tree. HasAttributes Whether the node has attributes. HasValue Whether the node can have a text value. IsDefault Whether an Attribute
node was generated from the default value defined in the DTD or schema.IsEmptyElement Whether an Element
node is empty.LocalName The local name of the node. Name The qualified name of the node, equal to Prefix
:LocalName
.NamespaceUri The URI defining the namespace associated with the node. NodeType The XmlNodeType of the node. Prefix A shorthand reference to the namespace associated with the node. QuoteChar The quotation mark character used to enclose the value of an attribute. Value The text value of the node. XmlLang The xml:lang
scope within which the node resides.EntityReference
node.This class checks that a Document Type Definition (DTD) is well-formed, but does not validate using the DTD.
To read strongly typed data, use the XmlConvert class.
This class throws a XmlException on XML parse errors. After an exception is thrown, the state of the reader is not predictable. For example, the reported node type might be different than the actual node type of the current node.
[Note: This class is
abstract
and implemented in the XmlTextReader class.]
DefaultMemberAttribute("Item")
System.Xml Namespace
XmlReader Constructors
XmlReader Methods
XmlReader.Close Method
XmlReader.GetAttribute(System.String) Method
XmlReader.GetAttribute(System.String, System.String) Method
XmlReader.GetAttribute(int) Method
XmlReader.IsName Method
XmlReader.IsNameToken Method
XmlReader.IsStartElement(System.String, System.String) Method
XmlReader.IsStartElement(System.String) Method
XmlReader.IsStartElement() Method
XmlReader.LookupNamespace Method
XmlReader.MoveToAttribute(int) Method
XmlReader.MoveToAttribute(System.String, System.String) Method
XmlReader.MoveToAttribute(System.String) Method
XmlReader.MoveToContent Method
XmlReader.MoveToElement Method
XmlReader.MoveToFirstAttribute Method
XmlReader.MoveToNextAttribute Method
XmlReader.Read Method
XmlReader.ReadAttributeValue Method
XmlReader.ReadElementString(System.String, System.String) Method
XmlReader.ReadElementString(System.String) Method
XmlReader.ReadElementString() Method
XmlReader.ReadEndElement Method
XmlReader.ReadInnerXml Method
XmlReader.ReadOuterXml Method
XmlReader.ReadStartElement() Method
XmlReader.ReadStartElement(System.String) Method
XmlReader.ReadStartElement(System.String, System.String) Method
XmlReader.ReadString Method
XmlReader.ResolveEntity Method
XmlReader.Skip Method
XmlReader Properties
XmlReader.AttributeCount Property
XmlReader.BaseURI Property
XmlReader.CanResolveEntity Property
XmlReader.Depth Property
XmlReader.EOF Property
XmlReader.HasAttributes Property
XmlReader.HasValue Property
XmlReader.IsDefault Property
XmlReader.IsEmptyElement Property
XmlReader.Item(int) Property
XmlReader.Item(System.String) Property
XmlReader.Item(System.String, System.String) Property
XmlReader.LocalName Property
XmlReader.Name Property
XmlReader.NameTable Property
XmlReader.NamespaceURI Property
XmlReader.NodeType Property
XmlReader.Prefix Property
XmlReader.QuoteChar Property
XmlReader.ReadState Property
XmlReader.Value Property
XmlReader.XmlLang Property
XmlReader.XmlSpace Property
protected XmlReader();
Constructs a new instance of the XmlReader class.
System.Xml.XmlReader Class, System.Xml Namespace
public abstract void Close();
Changes the System.Xml.XmlReader.ReadState to System.Xml.ReadState.Closed.
[Behaviors: This method releases any resources allocated by the current instance, changes the System.Xml.XmlReader.ReadState to System.Xml.ReadState.Closed, and calls theClose
method of any underlying Stream or TextReader instance. ]
[Overrides: This method must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract string GetAttribute(string name);
Returns the value of the attribute with the specified qualified name.
- name
- A String specifying the qualified name of the attribute.
A String containing the value of the specified attribute, ornull
if the attribute is not found.
[Behaviors: This method does not move the reader. ]
[Overrides: This method must be overridden in order to provide the functionality described above, as there is no default implementation. ]
For an example demonstrating this method, see System.Xml.XmlTextReader.GetAttribute(System.Int32)(String, String).
System.Xml.XmlReader Class, System.Xml Namespace
public abstract string GetAttribute(string name, string namespaceURI);
Returns the value of the attribute with the specified local name and namespace URI.
- name
- A String specifying the local name of the attribute.
- namespaceURI
- A String specifying the namespace URI of the attribute.
A String containing the value of the specified attribute, ornull
if the attribute is not found.
[Behaviors: This method does not move the reader. ]
[Overrides: This method must be overridden in order to provide the functionality described above, as there is no default implementation. ]
For an example demonstrating this method, see System.Xml.XmlTextReader.GetAttribute(System.Int32)(String, String).
System.Xml.XmlReader Class, System.Xml Namespace
public abstract string GetAttribute(int i);
Returns the value of the attribute with the specified index relative to the containing element.
- i
- A Int32 specifying the zero-based index of the attribute relative to the containing element.
A String containing the value of the specified attribute.
Exception Type Condition ArgumentOutOfRangeException i is less than 0, or greater than or equal to the System.Xml.XmlReader.AttributeCount of the containing element.
[Behaviors: This method does not move the reader. ]
[Overrides: This method must be overridden in order to provide the functionality described above, as there is no default implementation. ]
For an example demonstrating this method, see System.Xml.XmlTextReader.GetAttribute(System.Int32)(String, String).
System.Xml.XmlReader Class, System.Xml Namespace
public static bool IsName(string str);
Determines whether the specified string is a valid XML name.
- str
- A String specifying the name to validate.
A Boolean wheretrue
indicates the name is valid; otherwise,false
.
[Note: This method uses the W3C XML 1.0 Recommendation (http://www.w3.org/TR/2000/REC-xml-20001006#NT-Name) to determine whether the name is valid.]
System.Xml.XmlReader Class, System.Xml Namespace
public static bool IsNameToken(string str);
Determines whether the specified string is a valid XML name token (Nmtoken).
- str
- A String specifying the name to validate.
A Boolean wheretrue
indicates the name is valid; otherwisefalse
.
[Note: This method uses the W3C XML 1.0 Recommendation (http://www.w3.org/TR/2000/REC-xml-20001006#NT-Nmtoken ) to determine whether the name token is valid.]
System.Xml.XmlReader Class, System.Xml Namespace
public virtual bool IsStartElement(string localname, string ns);
Determines if a node containing content is anElement
node with the specified local name and namespace URI.
- localname
- A String specifying the local name of an element.
- ns
- A String specifying the namespace URI associated with the element.
A Boolean wheretrue
indicates the node is anElement
node with the specified local name and namespace URI;false
otherwise.
Exception Type Condition XmlException An error occurred while parsing the XML.
[Behaviors: As described above. ]
[Default: This method calls the System.Xml.XmlReader.MoveToContent method, which determines whether the current node can contain content and, if not, moves the reader to the next content node or the end of the input stream. When the reader is positioned on a content node, the node is checked to determine if it is an
Element
node with System.Xml.XmlReader.LocalName and System.Xml.XmlReader.NamespaceURI properties equal to localname and ns, respectively. ]
[Overrides: Override this method to customize the behavior of this method in types derived from the XmlReader class. ]
[Usage: Use this method to determine whether the node returned by the System.Xml.XmlReader.MoveToContent method is an
Element
node with the specified local name and namespace URI. ]
System.Xml.XmlReader Class, System.Xml Namespace
public virtual bool IsStartElement(string name);
Determines if a node containing content is anElement
node with the specified qualified name.
- name
- A String specifying the qualified name of an element.
A Boolean wheretrue
indicates the node is anElement
node with the specified name;false
otherwise.
Exception Type Condition XmlException An error occurred while parsing the XML.
[Behaviors: As described above. ]
[Default: This method calls the System.Xml.XmlReader.MoveToContent method, which determines whether the current node can contain content and, if not, moves the reader to the next content node or the end of the input stream. When the reader is positioned on a content node, the node is checked to determine if it is an
Element
node with a System.Xml.XmlReader.Name property equal to name.]
[Overrides: Override this method to customize the behavior of this method in types derived from the XmlReader class. ]
[Usage: Use this method to determine whether the node returned by the System.Xml.XmlReader.MoveToContent method is an
Element
node with the specified name. ]
System.Xml.XmlReader Class, System.Xml Namespace
public virtual bool IsStartElement();
Determines if a node containing content is anElement
node.
A Boolean wheretrue
indicates the node is anElement
node;false
otherwise.
Exception Type Condition XmlException An error occurred while parsing the XML.
[Behaviors: As described above.]
[Default: This method calls the System.Xml.XmlReader.MoveToContent method, which determines whether the current node can contain content and, if not, moves the reader to the next content node or the end of the input stream. When the reader is positioned on a content node, the node is checked to determine if it is an
Element
node. ]
[Overrides: Override this method to customize the behavior of this method in types derived from the XmlReader class. ]
[Usage: Use this method to determine whether the node returned by the System.Xml.XmlReader.MoveToContent method is an
Element
node. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract string LookupNamespace(string prefix);
Resolves a namespace prefix in the scope of the current element.
- prefix
- A String specifying the prefix whose namespace URI is to be resolved. To return the default namespace, specify System.String.Empty.
A String containing the namespace URI to which the prefix maps. If prefix is not in System.Xml.XmlReader.NameTable or no matching namespace is found,null
is returned.
[Behaviors: As described above. ]
[Overrides: This method must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract void MoveToAttribute(int i);
Moves the position of the current instance to the attribute with the specified index relative to the containing element.
- i
- A Int32 specifying the zero-based index of the attribute relative to the containing element.
Exception Type Condition ArgumentOutOfRangeException i is less than 0 or greater than or equal to the System.Xml.XmlReader.AttributeCount of the containing element.
[Behaviors: After calling this method, the System.Xml.XmlReader.Name, System.Xml.XmlReader.NamespaceURI, and System.Xml.XmlReader.Prefix properties reflect the properties of current attribute.]
[Overrides: This method must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract bool MoveToAttribute(string name, string ns);
Moves the position of the current instance to the attribute with the specified local name and namespace URI.
- name
- A String specifying the local name of the attribute.
- ns
- A String specifying the namespace URI of the attribute.
A Boolean wheretrue
indicates the attribute was found; otherwise,false
. Iffalse
, the position of the current instance does not change.
[Behaviors: After calling this method, the System.Xml.XmlReader.Name, System.Xml.XmlReader.NamespaceURI, and System.Xml.XmlReader.Prefix properties reflect the properties of current attribute.]
[Overrides: This method must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract bool MoveToAttribute(string name);
Moves the position of the current instance to the attribute with the specified qualified name.
- name
- A String specifying the qualified name of the attribute.
A Boolean wheretrue
indicates the attribute was found; otherwise,false
. Iffalse
, the reader's position does not change.
[Behaviors: After calling this method, the System.Xml.XmlReader.Name, System.Xml.XmlReader.NamespaceURI, and System.Xml.XmlReader.Prefix properties reflect the properties of current attribute.]
[Overrides: This method must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public virtual XmlNodeType MoveToContent();
Determines whether the current node can contain content and, if not, moves the position of the current instance to the next content node or the end of the input stream.
The XmlNodeTypeof the content node, or System.Xml.XmlNodeType.None if the position of the reader has reached the end of the input stream.
Exception Type Condition XmlException An error occurred while parsing the XML.
[Note: The following members of XmlNodeType can contain content:Attribute
,CDATA
,Element
,EndElement
,EntityReference
,EndEntity
, andText
. ]
[Behaviors: As described above.]
[Default: If the current node is an
Attribute
node, this method moves the position of the reader back to theElement
node that owns the attribute. ]
[Overrides: Override this method to customize the behavior of this method in types derived from the XmlReader class. ]
[Usage: Use this method to determine whether the current node can contain content and, if not, move the position of the reader to the next content node. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract bool MoveToElement();
Moves the position of the current instance to the node that contains the currentAttribute
node.
A Boolean wheretrue
indicates the position of the reader was moved;false
indicates the reader was not positioned on anAttribute
node and therefore the position of the reader was not moved.
[Note: TheDocumentType
,Element
, andXmlDeclaration
members of XmlNodeType can contain attributes. ]
[Behaviors: As described above. ]
[Overrides: This method must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract bool MoveToFirstAttribute();
Moves the position of the current instance to the first attribute associated with the current node.
A Boolean wheretrue
indicates the current node contains at least one attribute; otherwise,false
.
[Behaviors: If System.Xml.XmlReader.AttributeCount is non-zero, the position of the reader moves to the first attribute; otherwise, the position of the reader does not change. ]
[Overrides: This method must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract bool MoveToNextAttribute();
Moves the position of the current instance to the next attribute associated with the current node.
A Boolean wheretrue
indicates the position of the reader moved to the next attribute;false
if there were no more attributes.
[Behaviors: As described above. ]
[Overrides: This method must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract bool Read();
Moves the position of the current instance to the next node in the stream, exposing its properties.
A Boolean wheretrue
indicates the node was read successfully, andfalse
indicates there were no more nodes to read.
Exception Type Condition XmlException An error occurred while parsing the XML.
[Behaviors: As described above. ]
[Overrides: This method must be overridden in order to provide the functionality as described herein, as there is no default implementation. ]
[Usage: When a reader is first created and initialized, there is no information available. Calling this method is required to read the first node. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract bool ReadAttributeValue();
Parses an attribute value into one or moreText
,EntityReference
, andEndEntity
nodes.
A Boolean wheretrue
indicates the attribute value was parsed, andfalse
indicates the reader was not positioned on an attribute node or all the attribute values have been read.
[Note: To parse anEntityReference
node, call the System.Xml.XmlReader.ResolveEntity method. After the node is parsed into child nodes, call the System.Xml.XmlReader.ReadAttributeValue method again to read the value of the entity.The System.Xml.XmlReader.Depth of an attribute value node is one plus the depth of the attribute node. When general entity references are stepped into or out of, the System.Xml.XmlReader.Depth increments or decrements by one, respectively.
]
[Behaviors: As described above. ]
[Overrides: Implementations that cannot expand general entities should return general entities as a single empty (System.Xml.XmlReader.Value equals System.String.Empty)
EntityReference
node. ]
[Usage: Use this method after calling System.Xml.XmlReader.MoveToAttribute(System.String) to read through the
Text
,EntityReference,
orEndEntity
nodes that make up the attribute value. Call the System.Xml.XmlReader.ResolveEntity method to resolve theEntityReference
nodes. ]
System.Xml.XmlReader Class, System.Xml Namespace
public virtual string ReadElementString(string localname, string ns);
Reads the contents of a text-only element with the specified local name and namespace URI.
- localname
- A String specifying the local name of an element.
- ns
- A String specifying the namespace URI associated with the element.
A String containing the contents of the element.
Exception Type Condition XmlException The node is not an Element
node, the System.Xml.XmlReader.LocalName property of theElement
node does not equal localname, or the System.Xml.XmlReader.NamespaceURI property of theElement
node does not equal ns, the element does not contain a simple text value, or an error occurred while parsing the XML.
[Behaviors: As described above. ]
[Default: This method calls the System.Xml.XmlReader.MoveToContent method. If the returned node is an
Element
node, this method compares the System.Xml.XmlReader.LocalName and System.Xml.XmlReader.NamespaceURI properties of the node to localname and ns, respectively. If they are equal, this method calls the System.Xml.XmlReader.ReadString method to read the contents of the element. ]
[Overrides: Override this method to customize the behavior of this method in types derived from the XmlReader class. ]
[Usage: Use this method to read the contents of a text-only element with the specified local name and namespace URI. ]
System.Xml.XmlReader Class, System.Xml Namespace
public virtual string ReadElementString(string name);
Reads the contents of a text-only element with the specified qualified name.
- name
- A String specifying the qualified name of an element.
A String containing the contents of the element.
Exception Type Condition XmlException The node is not an Element
node, the System.Xml.XmlReader.Name property of theElement
node does not equal name, the element does not contain a simple text value, or an error occurred while parsing the XML.
[Behaviors: As described above. ]
[Default: This method calls the System.Xml.XmlReader.MoveToContent method and, if the returned node is an
Element
node, compares the System.Xml.XmlReader.Name property of the node to name. If they are equal, this method calls the System.Xml.XmlReader.ReadString method to read the contents of the element. ]
[Overrides: Override this method to customize the behavior of this method in types derived from the XmlReader class. ]
[Usage: Use this method to read the contents of a text-only element with the specified qualified name. ]
System.Xml.XmlReader Class, System.Xml Namespace
public virtual string ReadElementString();
Reads the contents of a text-only element.
A String containing the contents of the element.
Exception Type Condition XmlException The node is not an Element
node, the element does not contain a simple text value, or an error occurred while parsing the XML.
[Behaviors: As described above. ]
[Default: This method calls the System.Xml.XmlReader.MoveToContent method and, if the returned node is an
Element
node, calls the System.Xml.XmlReader.ReadString method to read the contents. ]
[Overrides: Override this method to customize the behavior of this method in types derived from the XmlReader class. ]
[Usage: Use this method to read the contents of a text-only element. ]
System.Xml.XmlReader Class, System.Xml Namespace
public virtual void ReadEndElement();
Reads anEndElement
node and advances the reader to the next node.
Exception Type Condition XmlException The node is not an EndElement
node or an error occurred while parsing the XML.
[Behaviors: As described above. ]
[Default: This method calls the System.Xml.XmlReader.MoveToContent method, which determines whether the current node can contain content and, if not, moves the reader to the next content node or the end of the input stream. The node the reader ends up positioned on is checked to determine if it is an
EndElement
node. If so, the node is read and the reader is moved to the next node.]
[Overrides: Override this method to customize the behavior of this method in types derived from the XmlReader class. ]
[Usage: Use this method to read an
EndElement
node and advance the reader to the next node. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract string ReadInnerXml();
Reads the contents of the current node, including child nodes and markup.
A String containing the XML content, or System.String.Empty if the current node is neither an element nor attribute, or has no child nodes.
Exception Type Condition XmlException The XML was not well-formed, or an error occurred while parsing the XML.
[Behaviors: The current node and corresponding end node are not returned.If the current node is an element, after the call to this method, the reader is positioned after the corresponding end element.
If the current node is an attribute, the position of the reader is not changed.
[Note: For a comparison between this method and the System.Xml.XmlReader.ReadOuterXml method, see System.Xml.XmlTextReader.ReadInnerXml.
]
]
[Overrides: This method must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract string ReadOuterXml();
Reads the current node and its contents, including child nodes and markup.
A String containing the XML content, or System.String.Empty if the current node is neither an element nor attribute.
Exception Type Condition XmlException The XML was not well-formed, or an error occurred while parsing the XML.
[Behaviors: The current node and corresponding end node are returned.If the current node is an element, after the call to this method, the reader is positioned after the corresponding end element.
If the current node is an attribute, the position of the reader is not changed.
[Note: For a comparison between this method and the System.Xml.XmlReader.ReadOuterXml method, see System.Xml.XmlTextReader.ReadInnerXml.
]
]
[Overrides: This method must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public virtual void ReadStartElement();
Reads anElement
node and advances the reader to the next node.
Exception Type Condition XmlException The node is not an Element
node or an error occurred while parsing the XML.
[Behaviors: As described above. ]
[Default: This method calls the System.Xml.XmlReader.MoveToContent method, which determines whether the current node can contain content and, if not, moves the reader to the next content node or the end of the input stream. The node the reader ends up positioned on is checked to determine if it is an
Element
node. If so, the node is read and the reader is moved to the next node. ]
[Overrides: Override this method to customize the behavior of this method in types derived from the XmlReader class. ]
[Usage: Use this method to read an
Element
node and advance the reader to the next node. ]
System.Xml.XmlReader Class, System.Xml Namespace
public virtual void ReadStartElement(string name);
Reads anElement
node with the specified qualified name and advances the reader to the next node.
- name
- A String specifying the qualified name of an element.
Exception Type Condition XmlException The node is not an Element
node, the System.Xml.XmlReader.Name property of theElement
node does not equal name, or an error occurred while parsing the XML.
[Behaviors: As described above. ]
[Default: This method calls the System.Xml.XmlReader.MoveToContent method and, if the returned node is an
Element
node, compares the System.Xml.XmlReader.Name property of the node to name. If they are equal, this method calls the System.Xml.XmlReader.Read method to read the element and move to the next node. ]
[Overrides: Override this method to customize the behavior of this method in types derived from the XmlReader class. ]
[Usage: Use this method to read an
Element
node with the specified qualified name, and advance the reader to the next node. ]
System.Xml.XmlReader Class, System.Xml Namespace
public virtual void ReadStartElement(string localname, string ns);
Reads anElement
node with the specified local name and namespace URI and advances the reader to the next node.
- localname
- A String specifying the local name of an element.
- ns
- A String specifying the namespace URI associated with the element.
Exception Type Condition XmlException The node is not an Element
node, the System.Xml.XmlReader.LocalName property of theElement
node does not equal localname, the System.Xml.XmlReader.NamespaceURI property of theElement
node does not equal ns, or an error occurred while parsing the XML.
[Behaviors: As described above. ]
[Default: This method calls the System.Xml.XmlReader.MoveToContent method. If the returned node is an
Element
node, this method compares the System.Xml.XmlReader.LocalName and System.Xml.XmlReader.NamespaceURI properties of the node to localname and ns, respectively. If they are equal, this method calls the System.Xml.XmlReader.Read method to read the element and move to the next node. ]
[Overrides: Override this method to customize the behavior of this method in types derived from the XmlReader class. ]
[Usage: Use this method to read an
Element
node with the specified local name and namespace URI, and advance the reader to the next node. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract string ReadString();
Reads the contents of an element or text node as a string.
A String containing the contents of theElement
orText
node, or System.String.Empty if the reader is positioned on any other type of node.
Exception Type Condition XmlException An error occurred while parsing the XML.
[Behaviors: If positioned on anElement
node, this method concatenates allText
,SignificantWhitespace
,Whitespace
, andCDATA
node types, and returns the concatenated data as the element content. If none of these node types exist, System.String.Empty is returned. Concatenation stops when any markup is encountered, which can occur in a mixed content model or when an element end tag is read.If positioned on an element
Text
node, this method performs the same concatenation from theText
node to the element end tag. If the reader is positioned on an attributeText
node, this method has the same functionality as if the reader were position on the element start tag.]
[Overrides: This method must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract void ResolveEntity();
Resolves the entity reference forEntityReference
nodes.
Exception Type Condition InvalidOperationException The reader is not positioned on a System.Xml.XmlNodeType.EntityReference node.
[Behaviors: This method parses the entity reference into child nodes. When the parsing is finished a new System.Xml.XmlNodeType.EndEntity node is placed in the stream to close theEntityReference
scope. To step into the entity after this method has been called, call the System.Xml.XmlReader.ReadAttributeValue method if the entity is part of an attribute value, or the System.Xml.XmlReader.Read method if the entity is part of element content.If this method is not called, the parser moves to the next node past the entity (child nodes are bypassed).
]
[Overrides: This method must be overridden in order to provide the functionality as described in the Behaviors and Usage sections, as there is no default implementation.
This method is required to throw an exception for implementations that do not support schema or DTD information. In this case, the System.Xml.XmlReader.CanResolveEntity property is required to return
false
.]
[Usage: Use this method to resolve the entity reference for
EntityReference
nodes. Before calling this method, determine whether the reader can resolve an entity by checking the System.Xml.XmlReader.CanResolveEntity property. ]
System.Xml.XmlReader Class, System.Xml Namespace
public virtual void Skip();
Skips over the current element and moves the position of the current instance to the next node in the stream.
Exception Type Condition XmlException The XML was not well-formed, or an error occurred while parsing the XML.
[Behaviors: If the reader is positioned on a non-emptyElement
node (System.Xml.XmlReader.IsEmptyElement equalsfalse
), the position of the reader is moved to the node following the correspondingEndElement
node. The properties of the nodes that are skipped over are not exposed. If the reader is positioned on any other node type, the position of the reader is moved to the next node, in this case behaving like the System.Xml.XmlReader.Read method. ]
[Default: This method calls the System.Xml.XmlReader.MoveToElement method before skipping to the next node. ]
[Overrides: Override this method to customize the behavior of this method in types derived from the XmlReader class. ]
[Usage: Use this method to skip over the current node. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract int AttributeCount { get; }
Gets the number of attributes on the current node.
A Int32 containing the number of attributes on the current node, or zero if the current node does not support attributes.
[Note: This property is only relevant to theDocumentType
,Element
, andXmlDeclaration
node types of the XmlNodeType enumeration. Other node types do not have attributes. ]
[Behaviors: As described above.
This property is read-only.
]
[Overrides: This property must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract string BaseURI { get; }
Gets the base Uniform Resource Identifier (URI) of the current node.
The base URI of the current node.
[Note: A networked XML document is comprised of chunks of data aggregated using various W3C standard inclusion mechanisms and therefore contains nodes that come from different places. DTD entities are an example of this, but this is not limited to DTDs. The base URI tells where these nodes come from. If there is no base URI for the nodes being returned (for example, they were parsed from an in-memory string), System.String.Empty is returned. ]
[Behaviors: As described above.
This property is read-only.
]
[Overrides: This property must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public virtual bool CanResolveEntity { get; }
Gets a value indicating whether this reader can parse and resolve entities.
A Boolean equal tofalse
.
[Behaviors: This property returnstrue
to indicate the reader can parse and resolve entities; otherwise,false
.This property is read-only.
]
[Default: This property always returns
false
. ]
[Overrides: Override this property to return
true
for implementations that support schema or DTD information.]
[Usage: Use this property to determine whether the reader can parse and resolve entities. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract int Depth { get; }
Gets the depth of the current node in the XML document.
A Int32 containing the depth of the current node in the XML document.
[Behaviors: As described above.This property is read-only.
]
[Overrides: This property must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract bool EOF { get; }
Gets a value indicating whether the System.Xml.XmlReader.ReadState is System.Xml.ReadState.EndOfFile, signifying the reader is positioned at the end of the stream.
A Boolean wheretrue
indicates the reader is positioned at the end of the stream; otherwise,false
.
[Behaviors: As described above.This property is read-only.
]
[Overrides: This property must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public virtual bool HasAttributes { get; }
Gets a value indicating whether the current node has any attributes.
A Boolean wheretrue
indicates the current node has attributes; otherwise,false
.
[Behaviors: As described above.This property is read-only.
]
[Default: This property returns
true
if the System.Xml.XmlReader.AttributeCount property of the current node is greater than zero. ]
[Overrides: Override this property to customize the behavior of this property in types derived from the XmlReader class. ]
[Usage: Use this property to determine whether the current node has any attributes. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract bool HasValue { get; }
Gets a value indicating whether the current node can have an associated text value.
A Boolean wheretrue
indicates the node on which the reader is currently positioned can have an associated text value; otherwise,false
.
[Note: The following members of the XmlNodeType enumeration can have an associated value:Attribute
,CDATA
,Comment
,DocumentType
,ProcessingInstruction
,SignificantWhitespace
,Text
,Whitespace
, andXmlDeclaration
. ]
[Behaviors: As described above.
This property is read-only.
]
[Overrides: This property must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract bool IsDefault { get; }
Gets a value indicating whether the current node is an attribute that was generated from the default value defined in the DTD or schema.
A Boolean wheretrue
indicates the current node is an attribute whose value was generated from the default value defined in the DTD or schema;false
indicates the attribute value was explicitly set.
[Behaviors: As described above.This property is read-only.
]
[Overrides: This property should return
false
for implementations that do not support schema or DTD information. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract bool IsEmptyElement { get; }
Gets a value indicating whether the current node is an empty element (for example,<MyElement />
).
A Boolean wheretrue
indicates the current node is an element (System.Xml.XmlReader.NodeType equals System.Xml.XmlNodeType.Element) that ends with "/>
", otherwise,false
.
[Behaviors: A correspondingEndElement
node is not generated for empty elements.This property is read-only.
]
[Overrides: This property must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract string this[int i] { get; }
Retrieves the value of the attribute with the specified index relative to the containing element.
- i
- A Int32 specifying the zero-based index of the attribute relative to the containing element.
A String containing the value of the attribute.
Exception Type Condition ArgumentOutOfRangeException i is less than 0 or greater than or equal to the System.Xml.XmlReader.AttributeCount of the containing element.
[Behaviors: This property does not move the reader.]
[Overrides: This property must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract string this[string name] { get; }
Retrieves the value of the attribute with the specified qualified name.
- name
- A String specifying the qualified name of the attribute.
A String containing the value of the specified attribute, ornull
if the attribute is not found.
[Behaviors: This property does not move the reader.If the reader is positioned on a
DocumentType
node, this method can be used to get the PUBLIC and SYSTEM literals.]
[Overrides: This property must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract string this[string name, string namespaceURI] { get; }
Retrieves the value of the attribute with the specified local name and namespace URI.
- name
- A String specifying the local name of the attribute.
- namespaceURI
- A String specifying the namespace URI of the attribute.
A String containing the value of the specified attribute, ornull
if the attribute is not found.
[Behaviors: This property does not move the reader. ]
[Overrides: This property must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract string LocalName { get; }
Gets the local name of the current node.
A String containing the local name of the current node or, for node types that do not have a name (likeText
,Comment
, and so on), System.String.Empty.
[Behaviors: As described above. ]
[Overrides: This property must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract string Name { get; }
Gets the qualified name of the current node.
A String containing the qualified name of the current node or, for node types that do not have a name (likeText
,Comment
, and so on), System.String.Empty.
[Behaviors: The qualified name is equivalent to the System.Xml.XmlReader.LocalName prefixed with System.Xml.XmlReader.Prefix and the ':' character. For example, System.Xml.XmlReader.Name is "bk:book" for the element<bk:book>
.The name returned is dependent on the System.Xml.XmlReader.NodeType of the node. The following node types return the listed values. All other node types return an empty string.
This property is read-only.
Node Type Name Attribute
The name of the attribute. DocumentType
The document type name. Element
The tag name. EntityReference
The name of the entity referenced. ProcessingInstruction
The target of the processing instruction. XmlDeclaration
The literal string "xml". ]
[Overrides: This property must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract XmlNameTable NameTable { get; }
Gets the name table used by the current instance to store and look up element and attribute names, prefixes, and namespaces.
The XmlNameTable used by the current instance.
[Behaviors: Element and attribute names, prefixes, and namespaces are stored as individual String objects when a document is read.This property is read-only.
]
[Overrides: This property must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract string NamespaceURI { get; }
Gets the namespace URI associated with the node on which the reader is positioned.
A String containing the namespace URI of the current node or, if no namespace URI is associated with the current node, System.String.Empty.
[Behaviors: This property is relevant toElement
andAttribute
nodes only.Namespaces conform to the W3C "Namespaces in XML" recommendation, REC-xml-names-19990114.
This property is read-only.
]
[Overrides: This property must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract XmlNodeType NodeType { get; }
Gets the type of the current node.
One of the members of the XmlNodeType enumeration representing the type of the current node.
[Behaviors: This property does not return the following XmlNodeType members:Document
,DocumentFragment
,Entity
,EndEntity
, andNotation
.This property is read-only.
]
[Overrides: This property must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract string Prefix { get; }
Gets the namespace prefix associated with the current node.
A String containing the namespace prefix associated with the current node.
[Note: A namespace prefix is used as a reference for a namespace URI and is defined in an element declaration. For example,<someElement xmlns:bk="someURL">
, defines a prefix name "bk". ]
[Behaviors: As described above.
This property is read-only.
]
[Overrides: This property must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract char QuoteChar { get; }
Gets the quotation mark character used to enclose the value of an attribute.
A Char specifying the quotation mark character (" or ') used to enclose the value of an attribute.
[Behaviors: As described above.This property is read-only.
]
[Overrides: This property must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract ReadState ReadState { get; }
Gets the read state of the reader.
One of the members of the ReadState enumeration.
[Behaviors: As described above.This property is read-only.
]
[Overrides: This property must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract string Value { get; }
Gets the text value of the current node.
A String containing the text value of the current node.
[Behaviors: The value returned depends on the System.Xml.XmlReader.NodeType. The following table lists node types that have a value to return. All other node types return System.String.Empty.
This property is read-only.
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, or in the scope of xml:space = "preserve"
.Text
The content of the text node.
Whitespace
The white space between markup. XmlDeclaration
The content of the declaration. ]
[Overrides: This property must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract string XmlLang { get; }
Gets the currentxml:lang
scope.
A String containing the currentxml:lang
scope.
[Behaviors: As described above.This property is read-only.
]
[Overrides: This property must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace
public abstract XmlSpace XmlSpace { get; }
Gets the currentxml:space
scope.
One of the members of the XmlSpace enumeration. If noxml:space
scope exists, this property defaults to System.Xml.XmlSpace.None.
[Behaviors: As described above.This property is read-only.
]
[Overrides: This property must be overridden in order to provide the functionality described above, as there is no default implementation. ]
System.Xml.XmlReader Class, System.Xml Namespace