NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

XmlTextReader.GetAttribute (String, String)

Gets the value of the attribute with the specified name and namespace.

[Visual Basic]
Overloads Overrides Public Function GetAttribute( _
   ByVal name As String, _
   ByVal namespaceURI As String _
) As String
[C#]
public override string GetAttribute(
   string name,
   string namespaceURI
);
[C++]
public: override String* GetAttribute(
   String* name,
   String* namespaceURI
);
[JScript]
public override function GetAttribute(
   name : String,
   namespaceURI : String
) : String;

Parameters

name
The name of the attribute.
namespaceURI
[To be supplied.]

Return Value

The value of the specified attribute. If the attribute is not found, null is returned.

Exceptions

Exception Type Condition
ArgumentException The attribute specified by name and namespaceURI properties cannot be found in the current node.

Remarks

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.

See Also

XmlTextReader Class | XmlTextReader Members | System.NewXml Namespace | XmlTextReader.GetAttribute Overload List