开发者

Serializing An Object Into XML Java

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜