The input xml :
<books>
<book>
<name>Name1</name?
<title>Title</title>
</book>
</books>
I want to add new structure of book
oContent = // the xml input
var parseContentResult = jQuery.parseXML(oContent);
var xmlContent = $(parseContentResult),
booksAttr = xmlContent.find("books");
//New XML
var newXML =
"\t\t\n<book>" +
"\n\t\t\t<name>" + nameID + "</name>" +
"\n\t\t\t<title>" + titleId + "</title>";
}
newXML += "\t\t</book>\n" ;
//Update XML
var parseResult = jQuery.parseXML(newXML );
var xmlResult = $(parseResult );
booksAttr.append(xmlResult .find("book"));
return (new XMLSerializer()).serializeToString(xmlContent[0]);
The problem that I don't get the result in good strcture Did I do something wrong ?
No comments:
Post a Comment