【发布时间】:2011-05-09 01:43:05
【问题描述】:
我想去掉这个页面上的标签http://ptwc.weather.gov/feeds/ptwc_rss_indian.xml
只是想取上面xml中description标签之间的内容
a)为此我是否可以使用 xml 解析器或正则表达式
b) 如果我使用正则表达式如何去掉它? (我使用了下面的代码,但它不工作
Pattern p= Pattern.compile("<description>(.*)</description>",Pattern.DOTALL);
//Matcher matcher=p.matcher(result);
Matcher matcher = p.matcher(result);
if (matcher.matches())
{
String s1=matcher.group(1);
textView.setText(s1);
}
else
{
textView.setText("No Matches);
}
【问题讨论】:
-
Way to parse XML (org.w3c.Document) on Android 的可能重复项。此外,您不是要比较 xml 解析器,而是要询问如何解析文档。标题具有误导性。
-
我只是想知道使用 xml 解析器好还是我可以使用正则表达式去除标签?