Parse XML using DOM in android

后端 未结 5 2020
梦如初夏
梦如初夏 2020-12-22 13:39

Hi i want to parse XML and display list based on selection of user

my xml is looking like this

\"enter

5条回答
  •  独厮守ぢ
    2020-12-22 14:18

    The getElementsBytagName called on the document object will always return the list of all the nodes with the given tag name in the whole document. Instead, filter out the single company element you are interested in, and then call getElementsByTagName on it. E.g.

    Element companyEl = doc.getElementById(desiredCompanyId);
    if (companyEl != null) { // always good to check
        NodeList n1 = companyEl.getElementsByTagName("province");
    
        // your code here
    }
    

提交回复
热议问题