开发者

Serializing An Object Into XML Java

开发者 https://www.devze.com 2023-03-12 05:16 出处:网络
In C# we use serializer.ToXmlString/F开发者_开发百科romXmlString. Is there any Java equivalent for this?In java you use a javax.xml.transform.Transformer for DOM objects.

In C# we use serializer.ToXmlString/F开发者_开发百科romXmlString. Is there any Java equivalent for this?


In java you use a javax.xml.transform.Transformer for DOM objects.

TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
transformer.transform(new DOMSource(myDocument), new StreamResult(targetFile));

For regular java objects you might want to try XStream.

0

精彩评论

暂无评论...
验证码 换一张
取 消