简体   繁体   English

使用XStream将XML解析为POJO

[英]parse XML to POJO using XStream

I have an xml file which I want to read and parse it into POJO. 我有一个XML文件,我想阅读并将其解析为POJO。

I am using XStream for this. 我为此使用XStream。

I am not able to send the file as an input to the code for parsing(file is on my local drive). 我无法将文件作为输入发送到解析代码(文件在本地驱动器上)。

How to read the xml file and parse it using fromXML() method ? 如何使用fromXML()方法读取xml文件并进行解析?

I would be gratefull if someone can give example for sending xml file as input and parsing it to POJO and printing it on the screen 如果有人可以举一个例子发送XML文件作为输入并将其解析为POJO并将其打印在屏幕上,我将不胜感激

Thanks... 谢谢...

Based on the provided comments, I can better understand the problem you are facing. 根据提供的评论,我可以更好地理解您面临的问题。 I believe the answer you are looking for is implicit collections. 我相信您正在寻找的答案是隐式集合。 Check out the XStream tutorial on aliasing: http://x-stream.github.io/alias-tutorial.html . 查看有关别名的XStream教程: http : //x-stream.github.io/alias-tutorial.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM