Java 无法在android中解析具有不同名称值的xml

Java 无法在android中解析具有不同名称值的xml,java,android,xml,Java,Android,Xml,我的xml代码如下:- <MMP> <script id="tinyhippos-injected"/> <MERCHANT> <RESPONSE> <url>https://www.google.com</url> <param name="ttype">NBFundTransfer</param>

我的xml代码如下:-

 <MMP>
   <script id="tinyhippos-injected"/>
     <MERCHANT>
       <RESPONSE>
          <url>https://www.google.com</url>
            <param name="ttype">NBFundTransfer</param>
            <param name="tempTxnId">650398</param>
            <param name="token">7OhXxW7ndM0Ft%2B02bkgIHB0N0eKAMeiA2oeAjwTjiS</param>
            <param name="txnStage">1</param>
      </RESPONSE>
     </MERCHANT>
</MMP>

https://www.google.com
资金转移
650398
7OhXxW7ndM0Ft%2B02BKGIHB0N0EKAMEIA2EAJWTJIS
1.
这里我想要所有令牌的值,txnStage

我的android代码是:-

  try {
            URL url = new URL(URL1);
            DocumentBuilderFactory dbf = DocumentBuilderFactory
                    .newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            // Download the XML file
            doc = db.parse(new InputSource(url.openStream()));
            doc.getDocumentElement().normalize();
            // Locate the Tag Name
            nodelist = doc.getElementsByTagName("RESPONSE");
           for (int temp = 0; temp < nodelist.getLength(); temp++) {
            Node nNode = nodelist.item(temp);
            if (nNode.getNodeType() == Node.ELEMENT_NODE) {
                Element eElement = (Element) nNode;
                // Set the texts into TextViews from item nodes
                // Get the title
                textview.setText(textview.getText() + "Title : "
                        +eElement.getAttribute("name") + "\n" + "\n");
             }
           }

        } catch (Exception e) {
            Log.e("Error", e.getMessage());
            e.printStackTrace();
        }
试试看{
URL=新URL(URL1);
DocumentBuilderFactory dbf=DocumentBuilderFactory
.newInstance();
DocumentBuilder db=dbf.newDocumentBuilder();
//下载XML文件
doc=db.parse(新的输入源(url.openStream());
doc.getDocumentElement().normalize();
//找到标记名
nodelist=doc.getElementsByTagName(“响应”);
对于(int-temp=0;temp
使用此代码,我的文本视图中没有任何值。
任何人有任何想法,请与大家分享。

您的
节点列表
集合似乎只包含一个项目-表示
元素。此元素没有属性
name
集,因此不会填充任何内容。

如果(nNode.getNodeType()==Node.element\u Node){
条件是否正在执行?@ρ᜕ρρK,是的,它正在执行,textview.setText(“Title:+getNode(“url”,eeElement)+“\n”+“\n”);我得到的是url的值,而不是token,这意味着在TextView中得到
标题:
?@ρ∑ѕρєK,只把标题作为一个文本放入..或者如果我放入param,那么我只得到第一个值,即:-NBFundTransfer。。。。。。