Bug Tracker

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#9602 closed bug (duplicate)

Exception when adding a new node in XML.

Reported by: rcrathore Owned by: rcrathore
Priority: low Milestone: 1.next
Component: manipulation Version: 1.6.1
Keywords: Cc:
Blocked by: Blocking:


jsFiddle URL : http://jsfiddle.net/rcrathore/Y8DpM/[1]

I am trying to add a new node in XML using jQuery. Following code works fine in Firefox, Safari and Chrome but giving error in IE8:

<div id="result"> </div>

<div id="result2"> </div>

<script type="text/javascript"> <!--

var xml = "<root><node1><node2>TEXT1</node2></node1></root>" ; var $xml = $($.parseXML(xml)) ;

var newData = "<node3>234</node3>" ; var $newData = $($.parseXML(newData)); var newNode = null;

if (typeof document.importNode == 'function') {

newNode = document.importNode($newData.find('node3').get(0),true);

} else {

newNode = $newData.find('node3').get(0)


try {

$(newNode).appendTo($xml.find("node2")); /* expected TEXT1234*/ $("div#result").html($xml.text());

/* expected 234*/ $("div#result2").html($xml.find("root > node1 > node2 > node3").text());

} catch (e) {

alert(e) ; $("div#result").html("Error: " + e.description);


--> </script>

The error description on IE8 is "Wrong number of arguments or invalid property assignment".

[1]: http://jsfiddle.net/rcrathore/Y8DpM/

Change History (8)

comment:1 Changed 6 years ago by rcrathore

The code works in all browsers if I replace appendTo line


by :

$xml.find("node2").get(0).appendChild(newNode) ;

comment:2 Changed 6 years ago by Isaac


//Crash in IE
var $xml = $('<xml />').append($('<root />').append('<child />'));
//Works in IE
var $xml = $('<exml />').append($('<root />').append('<child />'));

comment:3 Changed 6 years ago by timmywil

Component: unfiledmanipulation
Owner: set to rcrathore
Priority: undecidedlow
Status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a reduced test case on http://jsfiddle.net that reproduces the issue experienced to help us assess your ticket.

Additionally, test against the jQuery (edge) version to ensure the issue still exists.

comment:4 Changed 6 years ago by rcrathore

Status: pendingnew

Isaac, timmywil:

  1. Not sure if Isaac's example is related.
  1. Not sure what can be reduced in my test case. I think it is already very compact. A root element has node2 and node2 and I am inserting a new node (node3) under node2.
Version 0, edited 6 years ago by rcrathore (next)

comment:5 Changed 6 years ago by kabel

comment:6 Changed 6 years ago by rcrathore

Thank you! kabel

comment:7 Changed 6 years ago by timmywil

Resolution: duplicate
Status: newclosed

comment:8 Changed 6 years ago by timmywil

Duplicate of #9370.

Note: See TracTickets for help on using tickets.