Java write xml stream to file


















Connect and share knowledge within a single location that is structured and easy to search. I am doing some data conversion like csv to xml with SAX then using transformer in Java. The result is in StreamResult, and I am trying to save this result to a file. If you give your Transformer such a StreamResult , it will write its result directly into the file you specified. I am not familiar with the API Stack Overflow for Teams — Collaborate and share knowledge with a private group.

Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. You can use a Serializer to write your XML to a file. You will need to make a new output stream to parse in the constructor of Serializer. Example Writing to a XML File using XOM is very similar to reading it except in this case we are making the instances instead of retrieving them off the root. They are listed below: appendChild String name - this will basically set the value of the element to name.

Elements are nodes so you can parse elements. File; import java. Pankaj I love Open Source technologies and writing about my experience about them is my passion.

Follow Author. Comments MrBigglesworth says:. June 27, at pm. Amit Jindal says:. June 12, at am. Vijay Kumar Kanta says:. July 2, at am. Priya says:. September 13, at am. Hary says:. ParserConfigurationException; import javax. OutputKeys; import javax.

Transformer; import javax. TransformerException; import javax. TransformerFactory; import javax. DOMSource; import javax. StreamResult; import org. Document; import org. Narayan Subedi Narayan Subedi 1, 2 2 gold badges 20 20 silver badges 44 44 bronze badges.

Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name.



0コメント

  • 1000 / 1000