简体   繁体   English

如何使用javascript访问特定节点下的xml节点?

[英]How to access xml nodes under a specific node using javascript?

<testimonials>
<testimonial id="4c050652f0c3e">
    <nimi>John</nimi>
    <email>test@test.com</email>
    <text>Some text</text>
    <active>1</active>
    </testimonial>
<testimonial id="4c05085e1cd4f">
    <name>ats</name>
    <email>some@test.ee</email>
    <text>Great site!</text>
    <active>0</akctive>
</testimonial>   </testimonials>

Hi, I was trying to access xml nodes using Javascript. 嗨,我正在尝试使用Javascript访问xml节点。 Can anyone explain me how to access all the nodes under the testimonial( with "id='4c050652f0c3e'"). 谁能解释我如何访问见证下的所有节点(“ id ='4c050652f0c3e'”)。

Thank you. 谢谢。

Use attribute selector in jquery 在jQuery中使用属性选择器

$("[category=cooking]").children().each(function(){
alert($(this).text());
});

DEMO 演示

Then you have to use direct id 然后,您必须使用直接ID

 $("#4c050652f0c3e").children().each(function () {
    alert($(this).text());
});

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

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