我有一个XML文件,我想从该文件中查找一些值我怎么可以这样使用jquery搜索标签值使用jQuery
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>ID</key>
<string>B0A6EF3C-221F-4918-89C2-340B05F6A7AD</string>
<key>Name</key>
<string>name</string>
<key>Items</key>
<array>
<dict>
<key>Mode</key>
<integer>1000</integer>
<key>background</key>
<string>RGBA:0.000000,1.000000,1.000000,1.000000</string>
<key>Enabled</key>
<true/>
</dict>
<dict>
<key>Mode</key>
<integer>1000</integer>
<key>background</key>
<string>RGBA:0.000000,1.000000,1.000000,1.000000</string>
<key>Enabled</key>
<true/>
</dict>
</array>
</dict>
</plist>
我该怎么如果我想搜索的值,例如获得第二<dict>
项目背景,怎么样使值,在这种情况下 真的,我想这样做jQuery的
这是我尝试到目前为止
$.post("demo.xml",{},function(xml){
// Run the function for each dict tag inside array tag in the XML file
$('array',xml).each(function(i) {
$(this).find('dict').each(function(){
$(this).find('key').each(function(){
key = $(this).text();
value = $(this).next().text();
alert("key = " + key + " value = "+ value);
});
});
});
上面的jQuery代码的工作很适合我,但每次返回键和它的价值。我想搜索特定值超出它例如
var value = $(this).find("background").value;
我想的名字,如“背景”
显示您尝试过的任何信息 – Hiral
您可以参考此链接; http://stackoverflow.com/questions/19220873/how-to-read-xml-file-contents-in-jquery-and-display-in-html-elements –
与哪些标签? – Shin