The following code fragment uses the xml file: "booksns.xml".
Get the value of the attribute with the specified name and namespace:
The result will be:
The getAttributeNS() method returns the value of the attribute with the specified name and namespace.
Note: This method is an XML method, and will not work with HTML documents.
Tip: Use the getAttributeNodeNS if you want to return the attribute as an Attr object.
![]()
The getAttributeNS() 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 get the value from, set this value to null if you dont want to specify a namespace |
| attributename | String | Required. The name of the attribute you want to get the value from |
| Type | Description |
|---|---|
| String | The specified attribute's value |
| DOM Version | Core Level 2 |
|---|
Your message has been sent to W3Schools.