开发者

static xml parsing

<!-- THIS XML IS USED AS REQUEST FOR 1) CALL RECORD SUBMISSION, 2) REJECTED CALL RECORD SUBMISSION -->
<xoomiPadRequest>
    <callRecord>
        <callInformation>
            <callRecordDateTime>11-18-2009 14:52:28</callRecordDateTime>
            <callRecordSubmittedDateTime>11-18-2009 15:00:45</callRecordSubmittedDateTime>      
            <products>
                <product>
                    <productId>1090</productId>
                    <productName>Invega</productName>
                    <productPriority>1</productPriority>
                </product>
                <product>
                    <productId>1091</productId>
                    <productName>Elmiron</productName>
                    <productPriority>2</productPriority>
                </product>  
                <product>
                    <productId>1092</productId>
                    <productName>Aciphex</productName>
                    <productPriority>3</productPriority>
                </product>  
                <product>
                    <productId>1093</productId>
                    <productName>Aci-jel</productName>
                    <productPriority>4</productPriority>
                </product>  
                <product>
                    <productId>1094</productId>
                    <productName>Axert</productName>
                    <productPriority>5</productPriority>
                </product>  
                <product>
                    <productId>1095</productId>
                    <productName>Caelyx</productName>
                    <productPriority>6</productPriority>
                </product>  
                <product>
                    <productId>1096</productId>
                    <productName>Cetraxal</productName>
                    <productPriority>7</productPriority>
                </product>  
                <product>
                    <productId>1097</productId>
                    <productName>Concerta</productName>
                    <productPriority>8</productPriority>
                </product>  
                <product>
                    <productId>1098</productId>
                    <productName>Doribax</productName>
                    <productPriority>9</productPriority>
                </product>  
                <product>
                    <productId>1099</productId>
                    <productName>Duragesic</productName>
                    <productPriority>10</productPriority>
                </product>              
        </products>
            <callType>Presentation</callType>
            <specialActivity>LOV from VP</specialActivity>
        </callInformation>
        <hcpInformation>
            <hcpUniqueIdentifier>HH353488</hcpUniqueIdentifier>
            <hcpLastName>Ryan</hcpLastName>
            <hcpFirstName>Tony</hcpFirstName>
            <hcpAcademicProfessionalTitle>Dr.</hcpAcademicProfessionalTitle>
            <!-- New tag which replaces the old address fields -->
            <hcpAddressId>1001</hcpAddressId>
            <hcpTelephoneNumber>(986) 654-1213</hcpTelephoneNumber>
            <hcpEmail>Tony.Ryan@email.com</hcpEmail>
            <hcpFaxNumber>(908) 776-522开发者_JS百科1</hcpFaxNumber>
            <!-- New tag for holding rep's rating of HCP -->
            <hcpRating>Good (4)</hcpRating>
        </hcpInformation>
        <repInformation>
            <repUniqueIdentifier>RR982398</repUniqueIdentifier>
            <repName>Bob Richard</repName>
            <repVoiceMailNumber>23232</repVoiceMailNumber>
            <repEmail>bob.richard@email.com</repEmail>
        </repInformation>       
    </callRecord>
</xoomiPadRequest>

above is my XML file.i want to parse it with my project.The screen contains checkboxes in listview.i want to display the names of products in my checkboxes.but i dont know how to parse it.plz help me...


To parse a XML use one of the DocumentBuilder's parse methods. DocumentBuilder instance can be received via DocumentBuilderFactory.newDocumentBuilder method


open t5he file as inputstream and:

 Document doc = null;
 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
 DocumentBuilder db = dbf.newDocumentBuilder();
 doc = db.parse(inputstream);

Now you can hndle the doch with e.g. doc.getElementsByTagName();

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜