0

我必须使用 sax 解析器解析两个不同的标签(CreatedClub 和 JoinedClub)响应并将响应更新到两个不同的列表视图中?我的回复如下:

<root> 
    <CreatedClub>
        <rows>
            <Cid>3590</Cid>
            <ClubName>Rockets</ClubName>
            <ClubAddress>A-44A,Sector-16</ClubAddress>
            <ClubCity>Noida</ClubCity>
            <ClubLatitude>28.5775157</ClubLatitude>
            <ClubLongitude>77.3159296</ClubLongitude>
            <ClubCreatedDate>2013-05-16T08:30:29.21-04:00</ClubCreatedDate>
            <photoPath>0</photoPath>
        </rows>
    </CreatedClub>
    <JoinedClub>
        <rows>
            <Cid>512</Cid>
            <ClubName>Delhi Rockets</ClubName> 
            <ClubAddress>New Friends Colony</ClubAddress>
            <ClubCity>New Delhi</ClubCity>
            <ClubLatitude>28.5670488</ClubLatitude>
            <ClubLongitude>77.2735599</ClubLongitude> 
            <ClubCreatedDate>2013-01-10T16:26:39.707-05:00</ClubCreatedDate>
            <photoPath>0</photoPath>
        </rows>
    </JoinedClub>
</root>              
4

1 回答 1

0

尝试这个

public void startElement(String uri, String localName, String qName,
            Attributes attributes) throws SAXException {
    super.startElement(uri, localName, qName, attributes);
    if (localName.equalsIgnoreCase("CreatedClub")) {
        //add to list1
    }else if (localName.equalsIgnoreCase("JoinedClub")) {
        //add to list2
        }

}
于 2013-05-23T12:09:42.217 回答