Editing an XML file using JavaScript?

Hey guys, I'm just learning JavaScript, and I have a question that I hope someone can answer. Is it possible to get an XML file (not HTML) from the server, add / remove / edit individual parts of it using client-side JavaScript, and then send it back to the server to save it? JSON or any other markup / data exchange format also works.

+3
source share
5 answers

Yes. Using jQuery ...

$.get("myGetUrl.php", function(data) {
  var xml = $(data);

  xml.find("myNode").text("newValue");

  $.post("myPostUrl.php", xml, function(resp) {
    alert(resp);
  }, "xml");
});
+3
source

Yes it is possible. See the XML DOM section and you can easily edit it on the client.

0
source

. XML- AJAX DOM, HTML. jQuery, .

0

. XMLHttpRequest, , , , XMLHttpRequest. XML ( , , ), , , JSON .

script (.. PHP, ASP, Ruby) , (.. JSON XML-) , .

, , , .

0

. XMLHttpRequest XML-, , MIME text/xml. responseText XML, XML DOM responseXML. DOM , .

JSON . XMLHttpRequest , jsonData = eval(xhr.responseText), JSON JavaScript.

JavaScript /, . XML JSON Ajax.

0

Source: https://habr.com/ru/post/1710845/


All Articles