这是最好的?XML解析器Android或正则表达式剥离出来XML? [英] Which is the best ?xml parser for android or Regex for stripping out xml?
问题描述
我要去掉从这个网页。 http://ptwc.weather.gov/标签供稿/ ptwc_rss_indian.xml
只是我想借此描述标签之间的内容在上面的XML
A)为此,我是否可以使用XML解析器或正则表达式
二)如果我使用正则表达式怎么去掉呢? (我用下面的code,但它不工作
模式P = Pattern.compile(<描述>(*)< /描述>中,Pattern.DOTALL);
//匹配器匹配= p.matcher(结果);
匹配匹配= p.matcher(结果); 如果(matcher.matches())
{
字符串S1 = matcher.group(1);
textView.setText(S1);
}
其他
{
textView.setText(不匹配);
}
我Aleadam同意,你应该总是使用XML解析器,但我也相信,一个XML解析器不应该是写一个麻烦或使用这就是为什么我总是建议使用href=\"http://simple.sourceforge.net/\" rel=\"nofollow\"> Android上的简单的XML框架的 正因如此,我甚至写了的如何使用简单的在Android中。 I want to strip out the tags from this page http://ptwc.weather.gov/feeds/ptwc_rss_indian.xml Just I want to take the content between description tags in the above xml a)For this whether I can use xml parser or regex b) If I use regex how to strip out that? (I used the below code but it's not working
I agree with Aleadam in that you should always use an XML Parser but I also believe that an XML parser should not be a hassle to write or use which is why I always recommend using the Simple XML Framework on Android. So much so that I even wrote a blog post on how to use Simple in Android. 这篇关于这是最好的?XML解析器Android或正则表达式剥离出来XML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!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);
}