繁体   English   中英

jQuery获取所有节点名称(父节点和子节点)

[英]jQuery get all node names (both parent and children)

我有一个由对象生成的XML文档。 我不知道在jQuery AJAX调用时它会是什么样子。 我想要做的是通过父和子获取节点名称来解析XML。

您可以提供的任何方向都将提供很好的服务。

谢谢!

你应该能够像解析jquery中的DOM元素一样解析XML;

http://jsfiddle.net/TBwm8/3/

var xml = "<root><stuff></stuff><stuff><stuffchild></stuffchild></stuff></root>";

function alertit(jqueryObject) {
    if (jqueryObject.length === 0) return;

    jqueryObject.each(function() {
        alert(this.nodeName.toLowerCase());
    });

    alertit(jqueryObject.children());
}

alertit($(xml));

你看过jParse吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM