|
System.Xml (system.xml.dll)
|
ECMA
|
This class is a simple reader for XML documents. XmlReader provides a non-cached,
forward-only navigation through an XML data stream. It does not provide
validation, nor does it expand general entities.
Two derived classes provide these
features: XmlTextReader and XmlValidatingReader.
The XmlReader class parses XML in a
streaming-based approach (exemplified by
the SAX specification). This means the XML parser presents "interesting pieces"
(elements, attributes, namespace declarations, and so forth) in a linear order. Within XmlReader, this ordering of nodes
is done using successive calls to the Read() method. An XmlReader is not positioned on a node at first — an
initial call to Read() is required to move to the root
node of a document. Subsequent calls to Read() move the
reader sequentially through the nodes. The NodeType
property tells you which type of node the reader is currently positioned on,
returning values from the XmlNodeType enumeration. A
special node-type value for XmlReader is EndElement. As Read() moves through
the stream, it can be positioned on an element's end tag after it has
stepped through the element's children. This is not a real node, in the DOM
sense, but is required for XmlReader to parse XML data
properly. The Skip() method steps through data node by
node. A call to Skip() moves the reader to the next
real node, disregarding the current node's children.
XML documents can also be parsed in a tree-based approach, using the XmlDocument type.
public abstract class XmlReader {
// Protected Constructors
protected method XmlReader();
// Public Instance Properties
public abstract field int AttributeCount{get; }
public abstract field string BaseURI{get; }
public virtual field bool CanResolveEntity{get; }
public abstract field int Depth{get; }
public abstract field bool EOF{get; }
public virtual field bool HasAttributes{get; }
public abstract field bool HasValue{get; }
public abstract field bool IsDefault{get; }
public abstract field bool IsEmptyElement{get; }
public abstract field string LocalName{get; }
public abstract field string Name{get; }
public abstract field string NamespaceURI{get; }
public abstract field XmlNameTable NameTable{get; }
public abstract field XmlNodeType NodeType{get; }
public abstract field string Prefix{get; }
public abstract field char QuoteChar{get; }
public abstract field ReadState ReadState{get; }
public abstract field string this{get; }
public abstract field string this{get; }
public abstract field string this{get; }
public abstract field string Value{get; }
public abstract field string XmlLang{get; }
public abstract field XmlSpace XmlSpace{get; }
// Public Static Methods
public static method bool IsName(string str);
public static method bool IsNameToken(string str);
// Public Instance Methods
public abstract method void Close();
public abstract method string GetAttribute(int i);
public abstract method string GetAttribute(string name);
public abstract method string GetAttribute(string name,
string namespaceURI);
public virtual method bool IsStartElement();
public virtual method bool IsStartElement(string name);
public virtual method bool IsStartElement(string localname,
string ns);
public abstract method string LookupNamespace(
string prefix);
public abstract method bool MoveToAttribute(string name);
public abstract method bool MoveToAttribute(string name,
string ns);
public abstract method void MoveToAttribute(int i);
public virtual method XmlNodeType MoveToContent();
public abstract method bool MoveToElement();
public abstract method bool MoveToFirstAttribute();
public abstract method bool MoveToNextAttribute();
public abstract method bool Read();
public abstract method bool ReadAttributeValue();
public virtual method string ReadElementString();
public virtual method string ReadElementString(
string name);
public virtual method string ReadElementString(
string localname, string ns);
public virtual method void ReadEndElement();
public abstract method string ReadInnerXml();
public abstract method string ReadOuterXml();
public virtual method void ReadStartElement();
public virtual method void ReadStartElement(string name);
public virtual method void ReadStartElement(
string localname, string ns);
public abstract method string ReadString();
public abstract method void ResolveEntity();
public virtual method void Skip();
}
Subclasses
XmlNodeReader, XmlTextReader, XmlValidatingReader
Returned By
XmlValidatingReader.Reader, System.Xml.Xsl.XslTransform.Transform()
Passed To
XmlDocument.{Load(), ReadNode()}, XmlValidatingReader.XmlValidatingReader(), XmlWriter.{WriteAttributes(), WriteNode()}, System.Xml.XPath.XPathDocument.XPathDocument(), System.Xml.Xsl.XslTransform.Load()