- 帖子
- 2
- 积分
- 15
- 技术
- 0
- 捐助
- 0
- 注册时间
- 2010-6-6
|
[文本处理] 怎么获取一个XML文件中指定行的内容?然后过滤该行不需要的字符
有一个XML文件内容如下:
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>每日一句</title>
<link>http://dict.hjenglish.com/daily</link>
<description>每日一句,积少成多,让你的英语口语跳出来</description>
<pubDate>Thu, 08 Sep 2011 02:48:59 GMT</pubDate>
<lastBuildDate>Thu, 08 Sep 2011 02:48:59 GMT</lastBuildDate>
<generator>Rss Generator By dict.hjenglish.com</generator>
<item>
<title>It feels like spring.</title>
<link>http://bulo.yeshj.com/menu/1497/item/459695/</link>
<pubDate>2011-09-08</pubDate>
<description>It feels like spring./感觉好像春天到了。 </description>
<enclosure>http://d1.g.hjfile.cn/voice/daily_en/dy_1395.mp3</enclosure>
<en_sentence>It feels like spring.</en_sentence>
<cn_sentence>感觉好像春天到了。 </cn_sentence>
<flashsound>http://dict.hjenglish.com/speaker_sent.swf?w=dy_1395</flashsound>
</item>
</channel>
</rss>
该XML是沪江英语的每日一句的文件,假设每天的每日一句都是记录在指定行的,不会变化。我需要获取 <description>It feels like spring./感觉好像春天到了。 </description>这一行的内容
。然后过滤掉前后的<description></description>,最好It feels like spring./感觉好像春天到了。中间的/也去掉,换成空格
我折腾好几天了,都达不到自己要的效果,烦劳帮忙。 |
|