如何在android中使用SAXparsing解析以下代码?

时间:2011-04-05 07:25:40

标签: android xml saxparser

<channel>
 <pubDate> <![CDATA[ 1301565012]]>  </pubDate>
 <name><![CDATA[ Nanopress]]> </name>
 <link><![CDATA[ http://www.nanopress.it ]]> </link>
<description> <![CDATA[ Tutte le ultime news di Nanopress ]]>  </description>
<language><![CDATA[ it ]]> </language>
 <item> <ID>0</ID> <url>
 <![CDATA[ http://www.politica24.it/articolo/giustizia-prescrizione-breve-caos-alla-camera-il-video/10129/ ]]> </url>
<category><![CDATA[ NanoPress ]]> </category>
 <title> <![CDATA[ Prescrizione breve: caos alla Camera ]]>  </title>
</channel>

1 个答案:

答案 0 :(得分:0)

org.xml.sax包含在Android SDK中,您可以像解决基本Java应用程序一样解析xml。

创建一个扩展DefaultHandler的类,实现SAXParserFactory并开始解析

SAXParserFactory saxFactory = SAXParserFactory.newInstance();
SAXParser parser = saxFactory.newSAXParser();

parser.parse( xml, handler );