StringWriter writer = new StringWriter();
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.transform(new DOMSource(node), new StreamResult(writer));
out.print("<zhape>"+writer.toString()+"</zhape>");
当我使用上面的代码时,以下行也出现在输出中。
<?xml version="1.0" encoding="UTF-8"?>
我怎样才能省略它而只获取 XML 内容。