RE: [xmljs-users] deep copy nodes between xml documents with JS
Brought to you by:
djoham,
witchhunter
From: David J. <dj...@ya...> - 2004-12-16 06:06:09
|
> copy a node (and it's children) from one xml doc (arriving on the page > via xmlhttprequest) to another (the master already created in the page). I think herein lies my confusion. I was focusing too much on the DocumentFragment part. ImportNode is really the appropriate method to be calling for what you're trying to do. > yeah, that was the only way I could get it to work - but work it does! Yea! > thanx for your help, David always a pleasure > I'm using '.getAttribute(name)' elsewhere in the code but saw > 'getAttributeNode(name)' in the docs. Are they interchangable? Not directly... getAttributeNode breaks down to DOMElement.prototype.getAttributeNode = function DOMElement_getAttributeNode(name) { // delegate to DOMNamedNodeMap.getNamedItem return this.attributes.getNamedItem(name); }; getAttribute breaks down to DOMElement.prototype.getAttribute = function DOMElement_getAttribute(name) { var ret = ""; // if attribute exists, use it var attr = this.attributes.getNamedItem(name); if (attr) { ret = attr.value; } return ret; // if Attribute exists, return its value, otherwise, return "" }; So getAttributeNode gives you a node object while getAttribute will give you the node object's value, or "" if the query can't find what you're looking for. Best regards, David |