The identifier of the current node.
[Visual Basic] Public ReadOnly Property ID As XmlIdent [C#] public XmlIdent ID {get;} [C++] public: __property XmlIdent* get_ID(); [JScript] public function get ID() : XmlIdent;
The value of this property depends on the current NodeType as follows:
NodeType | Value |
---|---|
StartTag | An identifier with the name and namespace URI of the element. |
EndTag | A null reference. |
Text | An identifier with the name "#text" and an empty namespace URI. |
CData | An identifier with the name "#cdata" and an empty namespace URI. |
Comment | An identifier with the name "#comment" and an empty namespace URI. |
PI | An identifier with a name that starts with '?' and an empty namespace URI. |
Header | An identifier with the name "?xml" and an empty namespace URI. |
DocType | An identifier with the name "#doctype" and an empty namespace URI. |
BOF | A null reference. |
EOF | A null reference. |
The identifier returned by the ID property is guaranteed to have been created in the XmlContext associated with the reader (the Context property can be used to obtain this context).
When an application tests for a particular identifier multiple times, it is significantly more efficient to obtain the XmlIdent instance for the identifier once and compare against that than it is to directly test the ID.Name and ID.Namespace properties. For example:
while (reader.IsStartTag()) { if (reader.ID.Name == "order" && reader.ID.Namespace == "urn:acme.order") { ... } }
is significantly more efficient when written:
XmlIdent idOrder = reader.Context.GetID("order", "urn:acme.order"); while (reader.IsStartTag()) { if (reader.ID == idOrder) { ... } }