Get an attribute of a dom node

后端 未结 2 1728
一个人的身影
一个人的身影 2021-02-06 21:03

I am trying to get an attribute of an xml node example:



I want to grab the name attribute of the car nod

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-06 21:27

    you can do it without using elements, like this:

    //HtmlTag represents any arbitrary node that you are trying to get its "car" attribute 
    
    if("HtmlTag".equals(node.getNodeName()))
     String nodeContent=node.getAttributes().getNamedItem("car").getNodeValue()
    

提交回复
热议问题