2010-11-01 111 views
1

我解析XML服務的內容時,它會在解析內容時產生問題 Brown Men  sockey「Growings for Movember」,當我這樣解析時使用DOM解析它導致布朗男士十六進制代碼後,解析不接受餘下的字符,這裏的代碼來解析使用DOM解析XML的問題

NodeList items = elt.getElementsByTagName(ITEM); 
      for (int i = 0; i < items.getLength(); i++) { 
       Message_desc message = new Message_desc(); 
       Node item = items.item(i); 
       NodeList properties = item.getChildNodes(); 
       for (int j = 0; j < properties.getLength(); j++) { 
        Node property = properties.item(j); 
        String name = property.getNodeName(); 
        if (name.equalsIgnoreCase(DESCRIPTION)) { 
         message.setDescription(property.getFirstChild().getNodeValue()); 
.....} 

什麼,我需要在這裏做,請幫幫我。

回答

0
NodeList nodeList = doc.getElementsByTagName("item"); 

     description = new TextView[nodeList.getLength()]; 

     for (int i = 0; i < nodeList.getLength(); i++) { 

      Node node = nodeList.item(i); 
      description[i] = new TextView(this); 

      Element fstElmnt = (Element) node; 
      NodeList dataList =  fstElmnt.getElementsByTagName("description"); 
      Element dataElement = (Element) dataList.item(0); 
      dataList = dataElement.getChildNodes(); 
      description[i].setText(((Node) dataList.item(0)).getNodeValue()); 
+0

swathi ...感謝您的回答...在回答問題之前,請檢查問題的日期。 – 2012-06-06 11:28:20