大家好我有一个XML数据作为字符串变量。它有很多套<item>...</item>
我想知道我可以如何提取<name>..</name>
所有<item>
集合的所有数据,并将它们输出到使用javascript的textarea?如何在JavaScript中输出xml字符串中的所有perticuler xml元素值?
* 注: *的getJSON抓住远程XML,并把它作为内容变量: XML设置例如:
<item>
<title>rober album</title>
<link></link>
<description></description>
<location></location>
<image_url></image_url>
<name>robert</name>
</item>
代码:
<script>
$.getJSON('http://anyorigin.com/get?url=http://asite.com/feed/latest&callback=?', function(data){
var Content = data.contents;
//here i want to parse all name element of remote xml and put it in textarea
});
</script>
</head>
<body>
<td><textarea rows="7" cols="15" name="outputtext" style="width: 99%;"></textarea></td>
这是非常不清楚。你说你有XML数据,但在第二段代码中有一个返回JSON数据的ajax调用。它是不相关的吗?你的XML存储在哪里? – 2013-05-11 12:08:38
感谢您的回复.getjson从远程服务器获取xml,现在我想解析来自该远程xml的所有名称元素.Gjjson将整个远程xml保存为字符串内容。 – user1788736 2013-05-11 12:13:34