列出xml中的xml节点和属性名
List xml nodes and attribute name from xml
如何从xml中检索node_names和attribute_names(不是节点或属性的值)是否可以使用jquery?
<Client>
<product name="astro">
<service_process name="ACID">
<host>pable</host>
<port>18848</port>
</servcice_process>
<service_process name="Mestro">
<host>Mico</host>
<port>18821</port>
</servcice_process>
</product>
</Client>
你可以这样开始:
var xml = '<Client><product name="astro"><service_process name="ACID"><host>pable</host><port>18848</port></servcice_process><service_process name="Mestro"><host>Mico</host><port>18821</port></servcice_process></product></Client>';
$(xml).each(function displayChildren (i, node) {
console.log(node.nodeName);
// traverse attributes
$.each(node.attributes, function (j, attr) {
console.log(attr.nodeName, attr.nodeValue);
});
// recursive call
$(node).children().each(displayChildren);
});
快速搜索显示该页面处理使用jQuery的XML解析。获取节点名称有点困难,但这里提供了获取它的方法。通过快速浏览,我假设您想要执行以下操作:
$(xml).each(function(){ //xml is the XML resource.
if($(this).attr("name")!=""){
alert("Name = " + $(this).attr("name"));
}
alert("Node = " + $(this).get(0).TagName);
});
我相信这应该没问题。
相关文章:
- LiveCycle Xml属性绑定
- 使用javascript查找xml属性值
- for循环,直到xml属性不为null.从最后一行开始javascript
- 无法使用 jquery 获取 xml 属性的值
- 使用 qml 读取多个 Xml 属性
- 在 HTML 页面中显示 XML 属性
- 更改XML文件中的XML属性值
- 在“跨记录”中查找XML属性的最大值
- 读取xml子节点jquery上的多个xml属性
- 使用正则表达式替换XML属性内错误字符串中的嵌套引号
- js查找具有另一个属性的xml属性
- XML属性中的Dojo网格值
- 基于XML属性更改样式的indesigncs6脚本不工作
- Jquery获取XML属性值,用转义不工作
- 使用javascript解析XML属性值
- javascript将XML属性推入数组
- 使用变量名查找XML属性值
- 使用javascript xpath检查带有XML属性的字符串值
- 打开/关闭XML属性状态
- 如何使用jquery获得Xml属性?