DOM Node to XML

Posted on 2008-11-12
Last Modified: 2013-12-29
Can some one please let me know if there is a utility/method to convert a DOM node to an XML. I have manipulated the Node object and I want to see it's contents. Can I print it in the form of an XML?
Thank you
Question by:julie_456
    LVL 10

    Expert Comment

    use a transformer
    LVL 10

    Accepted Solution

    this code will print the XML to standard output
    TransformerFactory.newInstance().newTransformer().transform(new DOMSource(node), new StreamResult(System.out) ) ;

    Open in new window

    LVL 12

    Expert Comment

    by:Gibu George
    You can use JDOM to print the XML as it is

    XMLOutputter xmlOutPutter=new XMLOutputter();
    DOMBuilder domBuilder= new DOMBuilder();
    LVL 86

    Expert Comment

    If you want a quick and dirty way, see how it's done here:
    LVL 86

    Expert Comment

    It's a great pity that the JDK can offer nothing better than performing an xsl tranformation as a JDK-only way of doing one of the most fundamental things in XML programming

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Suggested Solutions

    Title # Comments Views Activity
    copyEndy  challenge 15 37
    matchUp  challenge 9 48
    array6 challenfge 6 48
    allStar challenge 1 27
    Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
    Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now