且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用jquery创建xml文件

更新时间:2023-01-02 11:12:13

使用 jQuery.parseXML 来解析一个简单的容器字符串:

Use jQuery.parseXML to parse a trivial container string:

var xml = '<?xml version="1.0"?><root/>';
var doc = jQuery.parseXML(xml);

然后,您可以使用普通的jQuery DOM操作将节点附加到该XML文档。一旦您需要序列化最终文档,您可以使用此问题。

Then you can use normal jQuery DOM manipulation to append nodes to that XML document. Once you need to serialize the final document, you can use the answers to this question.