, , - DOM XML-, URI .
, , MDN Attr.namespaceURI ( ):
Namespaces in XML , . , .
, , XML DOMParser XMLDocument:
<book> id, .
const XML = '<?xml version="1.0" encoding="utf-8"?>\
<books xmlns:lib="http://example.com/xml/library">\
<book id="book-one" lib:id="1">\
</book>\
</books>';
var parser = new DOMParser;
var doc = parser.parseFromString( XML, 'application/xml' );
console.log( doc instanceof XMLDocument );
var attributes = doc.querySelector( 'book' ).attributes;
for( var attribute of attributes ) {
console.log( attribute.localName, attribute.prefix, attribute.namespaceURI, attribute.value );
}
Hide result
- Attr node Element:
div2.setAttributeNode( div1.removeAttributeNode( div1.getAttributeNode( 'class' ) ) );
, , . , Element.getAttributeNode(), Element.getAttributeNodeNS(), Element.setAttributeNode() Element.setAttributeNodeNS() MDN.
DOM w3c.org (. 8.2 DOM Core), DOM whatwg