Convert String XML fragment to Document Node in Java

前端 未结 8 2198
迷失自我
迷失自我 2020-11-28 04:00

In Java how can you convert a String that represents a fragment of XML for insertion into an XML document?

e.g.

String newNode =  \"valu         


        
8条回答
  •  孤独总比滥情好
    2020-11-28 04:06

    If you're using dom4j, you can just do:

    Document document = DocumentHelper.parseText(text);

    (dom4j now found here: https://github.com/dom4j/dom4j)

提交回复
热议问题