Reads the next available attribute.
[Visual Basic] Public Function ReadAttr() As XmlAttribute [C#] public XmlAttribute ReadAttr(); [C++] public: XmlAttribute ReadAttr(); [JScript] public function ReadAttr() : XmlAttribute;
The next attribute in the current start tag.
Exception Type | Condition |
---|---|
XmlException | If the reader is not positioned on a start tag, or if all attributes of the start tag have already been read. |
The reader must be positioned on a start tag and the HasAttr property must be true. If this is not the case, an exception is thrown.
The ReadAttr method is typically used in a loop of the form:
while (reader.HasAttr) { XmlAttribute a = reader.ReadAttr(); Console.WriteLine("{0}='{1}'", a.ID, a.Value); }
There is no requirement that all attributes be read before a reader can be advanced to the next XML node.
To obtain the value of an attribute with a particular name or identifier, use one of the GetAttr methods.
XmlReader Class | XmlReader Members | System.Xml Namespace | HasAttr