So i am trying to do this. Add new root element and wrap old one in it.
Given this as starting condition
// this part uses SAXParser
org.w3c.com.Document = xmlSrc.parse(is); // *is* is InputStream
The initial condition is not really negotiable but I am open to hear comments there too
So given this xml file
<?xml version="1.0" encoding="UTF-8"?>
<root1>
<elem>...</elem>
</root1>
I need in Java to generate an InputStream that will contain xml file in it of this format
<?xml version="1.0" encoding="UTF-8"?>
<newroot>
<root1>
<elem>...</elem>
</root1>
</newroot>
Stored in some InputStream isNewXML
I am curious what is the best way to go about doing this.
I am new to Java and java has billion ways to do the same thing so out in dark which would be the best
Using your example input, this creates the requested output. Ideally, you would handle exceptions and close inputstreams, output streams, and writers properly: