一個XML文件,我有一個像XML文件標籤:如何獲得整個文本,包括從與jQuery
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<legends>
<legend>
<number>1</number>
<legendString><ul><li>1.across:a system of rules of conduct or method of practice</li><li>1.down:a disagreement or argument about something important</li><li>2.down:any broad thin surface</li><li>3.across:the passage of pedestrians or vehicles </li></ul></legendString>
</legend>
......
<legends>
我怎麼能走整個文本,包括使用jQuery的標籤。 字符串
<ul><li>1.across:a system of rules of conduct or method of practice</li><li>1.down:a disagreement or argument about something important</li><li>2.down:any broad thin surface</li><li>3.across:the passage of pedestrians or vehicles </li></ul>
如果我進行函數調用,應該傳遞。 如果我稱之爲:
var legendStr = $(this).find("legendString").text();
標籤將不會出現在legendStr。
我該怎麼做。
這是jQuery腳本:
var randomnumber=Math.floor(Math.random()*233);
$.get("legends.xml",{},function(xml){
$(xml).find("legend").each(function(){
if(randomnumber == $(this).find("number").text())
{
var c = "legendString";
var legendStr = $(this).find(c).html();
$("#sidebar > ul").html(legendStr);
}
});
},"xml");
這是行不通的。 – Vinod 2010-09-09 06:33:37
*不工作*不是一個非常準確的問題描述。你能發表一個完整的片段來說明這個問題嗎? – 2010-09-09 06:39:04
你可以看看更新的代碼。 – Vinod 2010-09-09 06:58:00