如何在没有循环的情况下获得elment childern
问题描述:
我有类似的XML结构
i have XML structure like that
<employees>
<employee id="10">
<name>jone</name>
</employee>
<employee id="20">
<name>adam</name>
</employee>
<employee id="35">
<name>tito</name>
</employee>
</employees>
如何使用jquery获取id = 20的员工姓名,请注意该员工我在任何位置(我是3元素或第一元素)
假设存储在变量中的XML文档名为xmfile
how to get the name of employee with id= 20 using jquery note that this employee my be at any position (my be 3 element or first element )
suppose that XML document stored in variable called xmfile
if($(xmfile).find("employee[id=10]").length > 0)
alert($(this).html());
答
(xmfile).find( 员工[id = 10])。长度> 0 )
alert(
(xmfile).find("employee[id=10]").length > 0) alert(
( this ) .html());
(this).html());
试试这个:
Try this:
var employees =