Gets the value of the attribute with the specified name and namespace.
[Visual Basic] Overloads Overrides Public Function GetAttribute( _ ByVal localName As String, _ ByVal namespaceURI As String _ ) As String [C#] public override string GetAttribute( string localName, string namespaceURI ); [C++] public: override String* GetAttribute( String* localName, String* namespaceURI ); [JScript] public override function GetAttribute( localName : String, namespaceURI : String ) : String;
The value of the specified attribute.
Exception Type | Condition |
---|---|
ArgumentException | The attribute specified by localName and namespaceURI properties cannot be found in the current node. |
The following XML contains an attribute in a specific namespace:
<test xmlns:dt="urn:datatypes" dt:type="int"/>
You can lookup the dt:type attribute using one argument (using Prefix+LocalName) or using two arguments (LocalName and NamespaceURI):
String dt = reader.GetAttribute("dt:type");
String dt2 = reader.GetAttribute("type","urn:datatypes");
Note that the xmlns attributes have no namespace URI; therefore, the only way to look them up is with the short version
String dt3 = reader.GetAttribute("xmlns:dt");
You can also get this information using the Prefix property.
DocumentNavigator Class | DocumentNavigator Members | System.NewXml Namespace | DocumentNavigator.GetAttribute Overload List