JQuery如何为XML对象添加节点

terry_hm 2011-07-03 03:21:33
例如xml对象结构如下:
<paras>
<para id='1'></para>
</paras>

如何通过JQuery为xml对象添加一个子节点,例如<para id='2'></para>
...全文
322 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
terry_hm 2011-07-03
  • 打赏
  • 举报
回复
已解决
/*
* jQuery XML Extension plugin
* Version 1.1 Beta (30-APR-2009)
* by Jeffrey Lee, http://blog.darkthread.net
*
* Examples:

$(function() {
var x = $("<xml><items><center /></items></xml>");
x.find("center").appendXml("<bottom />").prependXml("<top />");
x.find("center").afterXml("<after />").beforeXml("<before />");
alert(x.xml());
});

* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
terry_hm 2011-07-03
  • 打赏
  • 举报
回复
这样好像不成吧
sirzxj 2011-07-03
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 zell419 的回复:]

JScript code

var xml = $("<paras><para id='1'></para></paras>");
xml.append("<para id='2'></para>");


这样 ?
[/Quote]

估计楼主 不是这个意思
zell419 2011-07-03
  • 打赏
  • 举报
回复

var xml = $("<paras><para id='1'></para></paras>");
xml.append("<para id='2'></para>");

这样 ?

87,989

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧