<?xml version="1.0" encoding="utf-8"?>
<PlateTrees>
<Plate ID="1" Name="股票">
<Plate ID="2" Name="A股"></Plate>
<Plate ID="3" Name="港股"></Plate>
<Plate ID="4" Name="美股"></Plate>
</Plate>
<Plate ID="5" Name="外汇">
<Plate ID="6" Name="欧/美"></Plate>
<Plate ID="7" Name="镑/美"></Plate>
<Plate ID="8" Name="澳/美"></Plate>
<Plate ID="9" Name="美/日"></Plate>
<Plate ID="10" Name="美/加"></Plate>
<Plate ID="11" Name="美/瑞"></Plate>
</Plate>
</PlateTrees>
现在给你一个plate的ID,找出他的子plate。并且遍历他的所有子plate。
比如:找出ID为5的plate的子plate。谢谢!
<PlateTrees>
<Plate ID="1" Name="股票">
<Plate ID="2" Name="A股"></Plate>
<Plate ID="3" Name="港股"></Plate>
<Plate ID="4" Name="美股"></Plate>
</Plate>
<Plate ID="5" Name="外汇">
<Plate ID="6" Name="欧/美"></Plate>
<Plate ID="7" Name="镑/美"></Plate>
<Plate ID="8" Name="澳/美"></Plate>
<Plate ID="9" Name="美/日"></Plate>
<Plate ID="10" Name="美/加"></Plate>
<Plate ID="11" Name="美/瑞"></Plate>
</Plate>
</PlateTrees>
现在给你一个plate的ID,找出他的子plate。并且遍历他的所有子plate。
比如:找出ID为5的plate的子plate。谢谢!
alert($(this).attr("Name"));
});
我没测试过,不知道对不对。
alert($(this).find("ID").text())
})
$.get(
"xxx.xml",
function(xml){
var text = $(xml).find("Plate#2").text();
alert(text);
}
);
我想肯定是有两步,先找出ID为的Plate,然后再找出它的子plate,然后再遍历。
用jquery怎么写,是不是需要遍历,然后依次判断每个节点来找到ID为5的节点?
...
$("Plate[ID=5]",xmlDoc).children("Plate");