Something like this works:
Transformer transformer = TransformerFactory.newInstance().newTransformer();
Result output = new StreamResult(new File("output.xml"));
Source input = new DOMSource(myDocument);
transformer.transform(input, output);
More Related Contents:
- Normalization in DOM parsing with java – how does it work?
- Order of XML attributes after DOM processing
- Get a node’s inner XML as String in Java DOM
- XML Document to String
- What is the shortest way to pretty print a org.w3c.dom.Document to stdout?
- HTML/XML Parser for Java [closed]
- How to I output org.w3c.dom.Element to string format in java?
- Java: Most efficient method to iterate over all elements in a org.w3c.dom.Document?
- How to strip whitespace-only text nodes from a DOM before serialization?
- Getting XML Node text value with Java DOM
- Pretty print XML in java 8
- why is sax parsing faster than dom parsing ? and how does stax work?
- Unable to read xml with namespace prefix using DOM parser
- Create XML document using nodeList
- In Java, how do I parse XML as a String instead of a file?
- How to convert XML to java.util.Map and vice versa?
- How to group a 3×3 grid of radio buttons?
- Spring schemaLocation fails when there is no internet connection
- Is there a more elegant way to convert an XML Document to a String in Java than this code?
- The package org.w3c.dom is accessible from more than one module: , java.xml
- @XmlPath has no impact during the JAXB Marshalling
- Java + Mysql UTF8 Problem
- XML Node to String in Java
- Java : Convert formatted xml file to one line string
- Java/JAXB: Unmarshall XML attributes to specific Java object attributes
- Best method to parse various custom XML documents in Java
- Use JAXB to create Object from XML String
- Spring v3 no declaration can be found for element ‘mvc:resources’
- Parsing XML file containing HTML entities in Java without changing the XML
- Remove XML Node using java parser