douxing6532 2014-10-22 16:19
浏览 54

Android XML Parsing:解析这种特殊的XML类型我对此没有任何想法

This is XML URL

http://www.eboundservices.com/distribution/vod_new.xml

How we Parse in Android

<Aajkamrankhankaysath p0201="" p0801="" p0901="" p1501="" p1601="" p2201="" p2301="" p2901="" p3001="" p0702="" p2102="" p0303="" p0403="" p0603="" p1003="" p1103="" p1203="" p1303="" p1703="" p1803="" p1903="" p2003="" p2403="" p2503="" p2603="" p2703="" p2803="" p3103="" p0104="" p0204="" p0304="" p0404="" p0704="" p0804="" p0904="" p1004="" p1104="" p1404="" p1504="" p1604="" p1704="" p1804="" p2104="" p2204="" p2304="" p2404="" p2804="" p2904="" p3004="" p0105="" p0205="" p0505="" p0605="" p0705="" p0805="" p0905="" p1205="" p1305="" p1405="" p1505="" p1605="" p1905="" p2005="" p2105="" p2205="" p2305="" p2705="" p2805="" p2905="" p3005="" p0206="" p0306="" p0406="" p0506="" p2306="" p2406="" p2506="">25</Aajkamrankhankaysath>

I want to get like: p0201, p0801, p0901, p1501, p1501... and So On

I want to save in ArrayList, mean A TAG <> data in a AaaryList Respectively

  • 写回答

3条回答 默认 最新

  • dourang20110122 2014-10-22 18:43
    关注

    First of all these are attributes as someone has already mentioned. It is certainly a bad idea to have such a badly formed XML, even if the web-service is big I can see it's being developed in a very bad manner. Personal opinions aside, you will need to create your own class in order to populate a list of objects. You will need to read through every node, and populate every attribute manually and no short cut will work(as far as I know).

    public class TVNode {
        String p0210;
        String p0801;
        String p0901;
    
        // so on an so forth, define String mmembers for every attribute
        public TVNode()
        {
    
        }
    
        public void setp0210(String _p0210)
        {
        }
        public void setp0801(String _p0801)
        {
        }
        public void setp0901(String _p0901)
        {
        }
        // and getters too of course    
    }
    

    You'll have a list of TVNode type, you'll read the XML from either a file or web-response and once you have it you'll need to parse it using some type of XMLDOMParser. I hope this helps.

    评论

报告相同问题?