How to get the value using getElementsByTagName

后端 未结 1 1299
予麋鹿
予麋鹿 2020-12-18 09:34

How to get the value of the tag name using getElementsByTagName. My Xml file is


name
....
....



        
相关标签:
1条回答
  • 2020-12-18 10:09

    doc.getElementsByTagName("method") returns a NodeList.

    You want the first one of these, so you should use doc.getElementsByTagName("method").item(0) - which returns a Node.

    From this, you probably want the value; doc.getElementsByTagName("method").item(0).getTextContent() should get you that.

    0 讨论(0)
提交回复
热议问题