javaxmlsyncml

Print the syncml payload to a xml file


I want to print the syncml payload in a xml file before using it. Is there a method in java to print the syncml payload into a xml file or a way to check the payload?


Solution

  • Solved by converting it to a string. (able to find more details from --> http://www.theserverside.com/news/thread.tss?thread_id=26060)

    public void printXML(Document request){

        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();
        }
    }