import org.apache.xml.serialize.OutputFormat;
import org.apache.xml.serialize.XMLSerializer;
StringWriter stringOut = new StringWriter();
OutputFormat format = new OutputFormat(doc, "UTF-8", true);
try {
XMLSerializer serial = new XMLSerializer(stringOut, format);
serial.asDOMSerializer();
serial.serialize(doc.getDocumentElement());
} catch (Exception ex) {
ex.printStackTrace();
}
CString str=stringOut.toString();
//doc 为一个Document。str即为doc对应的XML的字符串表示。
希望能有帮助。
【 在 undeader 的大作中提到: 】
: 是org.w3c.dom.Document
: thx
: 【 在 undeader (weller) 的大作中提到: 】
: : toString好像不行啊?
: : 用java的,thx!