ADD tags to existing xml through java

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sunsom
    New Member
    • Mar 2008
    • 11

    ADD tags to existing xml through java

    i have a xml tag like this
    <ROOT>
    <CustomerOrde r>
    <ShipDate Value="5/15/2006"/>
    <LineItems>
    <LineItem>
    <BookID Value="1"/>
    <Price Value="3"/>
    <Quantity Value="10"/>
    </LineItem>
    </LineItems>
    </CustomerOrder>
    </ROOT>


    i want to add a tag <batch_tag> in between this xml like this
    <ROOT>
    <BATCH_TAG>
    <CustomerOrde r>
    <ShipDate Value="5/15/2006"/>
    <LineItems>
    <LineItem>
    <BookID Value="1"/>
    <Price Value="3"/>
    <Quantity Value="10"/>
    </LineItem>
    </LineItems>
    </CustomerOrder>
    </BATCH_TAG>
    </ROOT>

    how to do this through java? the customer order tag inside this xml can have multiple occurance....ki ndly help
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    Pick a java xml parsing technology. DOM, XSLT, VTD..

    How do you define where the batches start and end? Do all of them go into a single batch?

    XSLT would probably be the best choice for a small file.

    Comment

    • sunsom
      New Member
      • Mar 2008
      • 11

      #3
      the file could be 100 MB in size and the nuber of recorrd could be 10K. so for each record i need to append batch tags as mentioned in the sample xml above. i tried with VTD-Xml but it is not working for java 1.4.... kindly help out

      Comment

      • pronerd
        Recognized Expert Contributor
        • Nov 2006
        • 392

        #4
        Originally posted by sunsom
        the file could be 100 MB in size and the nuber of recorrd could be 10K. so for each record i need to append batch tags as mentioned in the sample xml above. i tried with VTD-Xml but it is not working for java 1.4.... kindly help out
        Please do not duplicate post the same question.
        http://bytes.com/forum/thread795113.ht ml

        Comment

        • kazam
          New Member
          • May 2008
          • 9

          #5
          check if this sample helps if you have DB2. This sample shows how to update the existing XML document.

          $HOME/sqllib/samples/xml/java/jdbc/XsUpdate.java

          Thanks,
          Madhavi


          Originally posted by sunsom
          i have a xml tag like this
          <ROOT>
          <CustomerOrde r>
          <ShipDate Value="5/15/2006"/>
          <LineItems>
          <LineItem>
          <BookID Value="1"/>
          <Price Value="3"/>
          <Quantity Value="10"/>
          </LineItem>
          </LineItems>
          </CustomerOrder>
          </ROOT>


          i want to add a tag <batch_tag> in between this xml like this
          <ROOT>
          <BATCH_TAG>
          <CustomerOrde r>
          <ShipDate Value="5/15/2006"/>
          <LineItems>
          <LineItem>
          <BookID Value="1"/>
          <Price Value="3"/>
          <Quantity Value="10"/>
          </LineItem>
          </LineItems>
          </CustomerOrder>
          </BATCH_TAG>
          </ROOT>

          how to do this through java? the customer order tag inside this xml can have multiple occurance....ki ndly help

          Comment

          Working...