Reputation: 21
I got the XML content with this and save into an other var:
$.get("content.xml",function(d){
....
xml=d;
}
Some code later:
$("tag_name_inXML",xml).text("new_content");
alert($("tag_name_inXML",xml).text()); //alerts the original content..why?
I've also tried this:
$(xml).find("tag_name_inXML").text("new_content");
alert($(xml).find("tag_name_inXML").text()); //also alerts the original content..why?
I just want to parse an XML, edit it and save it via PHP.
I also tried this:
$.get("content.xml",function(d){
....
xml=$(d);
}
...
xml.find("tag_name_inXML").text("new_content");
alert(xml.find("tag_name_inXML").text());//Alerts the NEW! content but..
...I can't send it by
$.get("save_xml.php",{xml_send:xml});
I got TypeError: Illegal Invocation
I've run out of ideas...
Upvotes: 2
Views: 97
Reputation: 8534
You just need convert the xml
, which is a jQuery object, to a string including the changed xml.
Following your these code:
$.get("content.xml",function(d){
....
xml=$(d);
}
...
xml.find("tag_name_inXML").text("new_content");
alert(xml.find("tag_name_inXML").text());//Alerts the NEW! content but..
Try change xml
to xml[0].outerHTML
:
$.get("save_xml.php",{xml_send:xml[0].outerHTML});
Upvotes: 2