Results 1 to 3 of 3

Thread: How to read xml attribute and value using staxEventItemReader

Hybrid View

  1. #1
    Join Date
    Mar 2012
    Posts
    22

    Default How to read xml attribute and value using staxEventItemReader

    Hi,

    I have problem in
    1.Mapping tag which contains attribute and value..for e.g
    <aid IdScope="Sender">20110421000008</aid >
    Here how to read IdScope attribute and its value.
    2.I am getting duplicate entry exception for following as unstructAddressLine tag is repeated.
    <UnstructAddress>
    <UnstructAddressLine>kabban park street</UnstructAddressLine>
    <UnstructAddressLine>shivaji nagar</UnstructAddressLine>
    <UnstructAddressLine>dharwad</UnstructAddressLine>
    </UnstructAddress>


    please help me to resolve these things.

    Thanks in advance
    sanjeev

  2. #2
    Join Date
    Sep 2008
    Location
    Chicagoland, IL
    Posts
    366

    Default

    1. Take a look at XStreamMarshaller#setUseAttributeFor(Map<Class, String>) where the Class is the class that was previously aliased and the String is the name of the attribute.
    2. Take a look at how to map collections (which I'm assuming UnstructAddress is) via XStreamMarshaller#setImplicitCollection.

    You can read more about mapping at the XStream level here: http://xstream.codehaus.org/alias-tutorial.html
    Michael Minella
    Spring Batch Lead
    Author - Pro Spring Batch
    http://www.michaelminella.com
    Twitter: @MichaelMinella

  3. #3
    Join Date
    Mar 2012
    Posts
    22

    Default

    Thanks minella,

    I went through the tutorial, there its mentioned about how to create xml from objects,my requirement is opposite.
    could you please tell How do i map the attribute and value of an element in configuration file.so that it will be helpful in reading xml.

    Thanks in advance..
    Sanjeev

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •