在Java中,如何转换表示XML片段的String,以便插入XML文档?
@H_502_1@例如
@H_502_1@然后将此节点作为给定节点的子节点插入到org.w3c.dom.Document中?
- String newNode = "<node>value</node>"; // Convert this to XML
- Element node = DocumentBuilderFactory
- .newInstance()
- .newDocumentBuilder()
- .parse(new ByteArrayInputStream("<node>value</node>".getBytes()))
- .getDocumentElement();