Jin Kwon
Jin Kwon

Reputation: 21976

Spring Batch Xml Item Read

I'm working with Spring Batch. I think I already know how I can parse good-looking xml and binding object.

And I stuck with this problem.

<parent>
  <child>
    <key name="xxx">
      <value>val</value>
    </key>
    <key name="yyy">
      <value>val</value>
    </key>
  </child>
</parent>

How can I parse xml items for above xml to children defined like this?

class Child {

    private String xxx;
    private String yyy;
}

I know how I can parse when it looks like this.

<parent>
  <child>
    <xxx>val</xxx>
    <yyy>val</yyy>
  </child>
</parent>

Is there any XPath like mappings with Spring-Batch's XML item reader?

Upvotes: 0

Views: 893

Answers (1)

Luca Basso Ricci
Luca Basso Ricci

Reputation: 18383

Use a Jaxb2Unmarshaller.
Check aroudn for a jaxb solution: it's full around the net.
In the worst case I remember you can write your own node parser and manage this form of your child tag.
I'm sorry but I can't add code because I'm not at work.
Hope can be help

Upvotes: 1

Related Questions