2011-05-11 149 views
0

我想使用HttpConnection解析XML文件,但我沒有得到正確的結果。 問題是xml文件中有很多屬性。 請告訴我如何解析具有SAX屬性的XML文件。 在android中使用SAX的XML解析

<person> 



    <lastname>Idris</lastname> 
<information MobileNo="xyz" AccountNo ="1234"Address ="abcdef"PhoneNo="12345"/> 


    <firstname>Nazmul</firstname> 

    <company>The Bean Factory, LLC.</company> 

    <email>[email protected]</email> 



</person> 

<lastname>Idris</lastname> 
<information MobileNo="xyz" AccountNo ="1234"Address ="abcdef"PhoneNo="12345"/> 

    <firstname>Nazmul</firstname> 

    <company>The Bean Factory, LLC.</company> 

    <email>[email protected]</email> 



</person> 

+0

請勿使用SAX使用簡單:https://massaioli.wordpress.com/2011/04/21/simple-xml-in-android-1-5-and-up/ – 2015-10-24 00:37:06

回答

0

在你的處理器級的,你有'的startElement() - 方法,其中有一個 'Attributes' -parameter。你可以使用'getValue()'方法從它讀取屬性值。