我想在使用之前在xml文件中打印syncml有效内容。 java中是否有方法将syncml有效负载打印到xml文件中或检查有效负载?
答案 0 :(得分:0)
通过将其转换为字符串来解决。 (能够从 - > http://www.theserverside.com/news/thread.tss?thread_id=26060找到更多细节)
public void printXML(文档请求){
try
{
DOMSource domSource = new DOMSource(request);
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = tf.newTransformer();
transformer.transform(domSource, result);
String checkpayload = writer.toString();
System.out.print(checkpayload);
}
catch(TransformerException ex)
{
ex.printStackTrace();
}
}