I am using xstream to parse XML and everything goes well while.... there is a situation that xstream seem can't handle it.
There's one tag named "", but in different xml file, it can contain text node or other XML tag.
It can be like this:
XML File 1:
<Spec> text Node Here </Spec>
XML File 2:
<Spec Id="1">
<Tag1>value</Tag1>
<Tag2>value</Tag2>
</Spec>
And In Spec class, I have this code...
@XStreamAlias("Spec")
@XStreamConverter(value = ToAttributedValueConverter.class, strings = { "spec" }) //when Text Node
public class Spec
{
String spec; // text Node
@XStreamAlias("Id")
@XStreamAsAttribute
String id;
@XStreamAlias("Tag1")
String tag1;
@XStreamAlias("Tag2")
String tag2;
// getter and setter...
}
in case of XML File 1, it works fine, but in case of XML File 2, values of fields "tag1" and "tag2" are null, and value of field "spec" is like : "\n\t\t"
What can I do to handle these two files? Thanks in advance!