html中如何显示网络访问得到的XML中的图片

来源:百度知道 编辑:UC知道 时间:2024/05/24 09:00:31
假如:http://stage.i33edu.com/得到如下xml:
<?xml version="1.0" encoding="utf-8" ?>
<root>
<list>
<user_id>1912603</user_id>
<video_id>483</video_id>
<video_title>
<![CDATA[ 二胡齐奏《包楞调》
]]>
</video_title>
<flvimg>http://stage.i33edu.com/01.jpg</flvimg>
<vote_count>7</vote_count>
<url>http://stage.i33edu.com/splay-483.html</url>
</list>
<list>
<user_id>1903968</user_id>
<video_id>465</video_id>
<video_title>
<![CDATA[ 小提琴合奏 小夜曲
]]>

你不就是想要得到图片名称吗,用不着去解析它了,用正则匹配出来就行了。以下示例能取得你想要的图片名称,保存在一个数组里。

var reg = /([^<>]+(?=<\/flvimg>))/gi;
var arr = str.match(reg); //假设xml内容被保存在str变量里
alert(arr.toString());