java - xStream problems - How to deserialize multiple objects -


I'm using xStream to manipulate XML, all is well. However, I have a problem to put on XML archive and other things:

Example: My XML has a tag, and inside it, I have & lt; Comment & gt; See some more examples of name tags:

  & lt; Comments & gt; & Lt; Comment & gt; & Lt; ID & gt; 1 & lt; / Id & gt; & Lt; Desc & gt; A comment & lt; / Desc> & Lt; / Comment & gt; & Lt; Comment & gt; & Lt; ID & gt; 2 & lt; / Id & gt; & Lt; Desc & gt; Another comment & lt; / Desc> & Lt; / Comment & gt; & Lt; Comment & gt; & Lt; ID & gt; 3 & lt; / Id & gt; & Lt; Desc & gt; One more comment & lt; / Desc> & Lt; / Comment & gt; & Lt; / Comments & gt;   

And progress can I tag 500 inside the tag. And these comments have commented types

How can I sort by xStream to put all these tags in the squares? How do I create different classes in class?

Obviously, I will do this with an array, or some other. But I do not know how I can do this.

For that XML, you might look like a square structure:

  public class comment {long id string description} public class comments {list & lt; Comment & gt; Comment = New Arrestist & lt; Comment & gt; (); }   

Your unmarshalling argument will be something like this:

  XStream xstream = new XStream (); Xstream.alias ("Comments", comments.class); Xstream.alias ("comment", comment class); Xstream.addImplicitCollection (comments category, "comments"); Comments Comments = (comments) xstream.fromXML (xml);   

As a joint, Mark has mentioned in the comments, your XML is not exactly created. You will need to make sure that your & lt; Comment & gt; & lt; / Comment & gt; and . You need to fix this before any code works in this answer.

Comments

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -