How do I remove a node element by id in XML?

后端 未结 2 1817
醉酒成梦
醉酒成梦 2021-01-21 11:12

Using: javax.xml and org.w3c:

public void removeNodeFromXML(File xmlfile_, String uuid)
  {
    DocumentBuilderFactory factory = Docume         


        
2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-21 11:50

    You can use XPath to select specific elements/attributes. Just search the web for Tutorials. Here is good one. You should also read the Java-Doc for java.xml.xpath, which includes short examples.

    The XPath-Expression for your XML-File is: /server[@ID='xxxx']

提交回复
热议问题