XML manipulation via Javascript

131 views
Skip to first unread message

Eric Patrick

unread,
Jul 3, 2012, 4:48:26 PM7/3/12
to mootool...@googlegroups.com
However, when I use clone(true) or cloneNode(true), the browser does not necessarily follow strict XML:

<input type="text" name="test"></input>

becomes

<input type="text" name="test">

To replicate, please see: http://jsfiddle.net/JDHQN/  

Any suggestions on a workaround?

Thanks in advance,

Eric Patrick

Eric Patrick

unread,
Jul 3, 2012, 4:55:27 PM7/3/12
to mootool...@googlegroups.com
Original context is missing; sorry!

I'm trying to allow for the manipulation of an XML document in memory via Javascript. So far, I am unable to clone XML nodes reliably; the browser appears to create HTML nodes instead of XML nodes.

Arian Stolwijk

unread,
Jul 3, 2012, 5:04:32 PM7/3/12
to mootool...@googlegroups.com
console.log only logs a representation of the nodes.
.clone() uses .cloneNode() (https://developer.mozilla.org/en/DOM/Node.cloneNode), so it shouldn't cause any problems.

Also see the note here: http://www.w3.org/TR/XMLHttpRequest/#the-responsexml-attribute, It isn't an actual XML document.

Arian Stolwijk

unread,
Jul 3, 2012, 5:05:32 PM7/3/12
to mootool...@googlegroups.com
That note should be added/changed in the MooTools docs probably...

Sanford Whiteman

unread,
Jul 3, 2012, 5:13:26 PM7/3/12
to Arian Stolwijk
> Also see the note here:
> http://www.w3.org/TR/XMLHttpRequest/#the-responsexml-attribute, It
> isn't an actual XML document.

I think that note clarifies it isn't *always* an XMLDocument object,
but it certainly can be depending on Content-Type and well-formedness.

-- S.

Reply all
Reply to author
Forward
0 new messages