The following code fragment uses the xml file: "booksns.xml".
Return the attribute with the specified name and namespace:
The result will be:
The getAttributeNodeNS() method returns the attribute with the specified name and namespace, as an Attr object.
Read more about the Attr Node object in our Attr Node object reference.
Note: This method is an XML method, and will not work with HTML documents.
Tip: Use the getAttributeNS() method if you just want to return the attribute value.
![]()
The getAttributeNodeNS() method is supported in all major browsers, except Internet Explorer.
Note: This method is an XML DOM method, and will not work with HTML documents.
| Parameter | Type | Description |
|---|---|---|
| namespaceURI | String | Required. The namespaceURI of the attribute you want to return, set this value to null if you dont want to specify a namespace |
| attributename | String | Required. The name of the attribute you want to return |
| Type | Description |
|---|---|
| Attr object | The specified attribute ndoe |
| DOM Version | Core Level 3 |
|---|
Your message has been sent to W3Schools.