hi,
I am using xstream with and without annotation, and it's pretty easy to use.
Right now I got a case I get nuts on.
Here's my XML:
[xml]<content>
<tag type="p">
...
</tag>
<tag type="p">
...
</tag>
<tag type="h">
...
</tag>
<tag type="p">
...
</tag>
</content>[/xml]
So content has a list of tags. A tag itself has the attribute type which can be p oder h. And tag has content. And this is the problematic part
Or without annotations:
But after unmarshalling the content.listTag.get(i).tag is always NULL where content.listTag.get(i).type is p oder h as expected.
Somehow its unmarshalling only the attribute but not the child node.
Who can help me on this?
Greetings and lots of thanks,
Marco Schmitz
I am using xstream with and without annotation, and it's pretty easy to use.
Right now I got a case I get nuts on.
Here's my XML:
[xml]<content>
<tag type="p">
...
</tag>
<tag type="p">
...
</tag>
<tag type="h">
...
</tag>
<tag type="p">
...
</tag>
</content>[/xml]
So content has a list of tags. A tag itself has the attribute type which can be p oder h. And tag has content. And this is the problematic part
Java:
@XStreamAlias("content")
public class Content {
@XStreamImplicit
public List<Tag> listTag = new ArrayList<Tag>();
}
@XStreamAlias("tag")
public class Tag {
@XStreamAsAttribute
public String type;
public String tag;
}
Or without annotations:
Java:
xstream.alias("content", Content.class);
xstream.addImplicitCollection(Content.class, "listTag", Tag.class);
xstream.alias("tag", String.class);
xstream.useAttributeFor(Tag.class, "type");
But after unmarshalling the content.listTag.get(i).tag is always NULL where content.listTag.get(i).type is p oder h as expected.
Somehow its unmarshalling only the attribute but not the child node.
Who can help me on this?
Greetings and lots of thanks,
Marco Schmitz
Zuletzt bearbeitet von einem Moderator: