1

I am using Xstream to parse XML file.

the ideal format of the XML file is:

<Line>
     <P Name="Src">5</P>
     <P Name="Dst">4</P>
</Line>

however, sometimes, the infomation would be:

<Line>
    <P Name="Src">2</P>
    <P Name="Points">[3, 0]</P>
    <Branch>
      <P Name="Points">[0, 8]</P>
      <P Name="Dst">5</P>
    </Branch>
    <Branch>
      <P Name="Dst">3</P>
    </Branch>
</Line>

The Points part could be ignored.

actually the above information means a fork line:

<Line>
     <P Name="Src">2</P>
     <P Name="Dst">5</P>
</Line>
<Line>
     <P Name="Src">2</P>
     <P Name="Dst">3</P>
</Line>

Can I use xstream to achieve this objective? split the branch into two Line object?

1 Answer 1

0

I would suggest to first transform the input XML using XSLT and then process the transformed XML using XStream:

Input XML -> XSLT -> Transformed XML -> XStream -> Java object(s)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.