Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2012
    Posts
    1
    Rep Power
    0

    Default xml file merging, based on the node.

    HI all,
    this is my first post on this forum, please help me in below regard:
    I have three xml files, I want to merge them but based on the node.
    This is the example:
    file1
    ---------------------
    <?xml version="1.0" ?>
    - <catalog>
    - <book id="bk101">
    <author>Gambardella, Matthew</author>
    <title>XML Developer's Guide</title>
    </book>
    - <book id="bk102">
    <author>Ralls, Kim</author>
    <title>Midnight Rain</title>
    </book>
    - <book id="bk103">
    <author>Corets, Eva</author>
    <title>Maeve Ascendant</title>
    </book>
    - <book id="bk104">
    <author>Corets, Eva</author>
    <title>Oberon's Legacy</title>
    </book>
    </catalog>

    file2
    --------------------------------------
    <?xml version="1.0" ?>
    - <catalog>
    - <book id="bk101">
    <genre>Computer</genre>
    <price>44.95</price>
    </book>
    - <book id="bk102">
    <genre>Fantasy</genre>
    <price>5.95</price>
    </book>
    - <book id="bk103">
    <genre>Fantasy</genre>
    <price>5.95</price>
    </book>
    - <book id="bk104">
    <genre>Fantasy</genre>
    <price>5.95</price>
    </book>
    </catalog>

    file3
    ------------------------------------------------
    <?xml version="1.0" ?>
    - <catalog>
    - <book id="bk101">
    <publish_date>2000-10-01</publish_date>
    <description>An in-depth look at creating applications with XML.</description>
    </book>
    - <book id="bk102">
    <publish_date>2000-12-16</publish_date>
    <description>A former architect battles corporate zombies, an evil sorceress, and her own childhood to become queen of the world.</description>
    </book>
    - <book id="bk103">
    <publish_date>2000-11-17</publish_date>
    <description>After the collapse of a nanotechnology society in England, the young survivors lay the foundation for a new society.</description>
    </book>
    - <book id="bk104">
    <publish_date>2001-03-10</publish_date>
    <description>In post-apocalypse England, the mysterious agent known only as Oberon helps to create a new life for the inhabitants of London. Sequel to Maeve Ascendant.</description>
    </book>
    </catalog>

    ================================================== =============

    now the final file should be like:
    <?xml version="1.0"?>
    <catalog>
    <book id="bk101">
    <author>Gambardella, Matthew</author>
    <title>XML Developer's Guide</title>
    <genre>Computer</genre>
    <price>44.95</price>
    <publish_date>2000-10-01</publish_date>
    <description>An in-depth look at creating applications
    with XML.</description>
    </book>
    <book id="bk102">
    <author>Ralls, Kim</author>
    <title>Midnight Rain</title>
    <genre>Fantasy</genre>
    <price>5.95</price>
    <publish_date>2000-12-16</publish_date>
    <description>A former architect battles corporate zombies,
    an evil sorceress, and her own childhood to become queen
    of the world.</description>
    </book>
    <book id="bk103">
    <author>Corets, Eva</author>
    <title>Maeve Ascendant</title>
    <genre>Fantasy</genre>
    <price>5.95</price>
    <publish_date>2000-11-17</publish_date>
    <description>After the collapse of a nanotechnology
    society in England, the young survivors lay the
    foundation for a new society.</description>
    </book>
    <book id="bk104">
    <author>Corets, Eva</author>
    <title>Oberon's Legacy</title>
    <genre>Fantasy</genre>
    <price>5.95</price>
    <publish_date>2001-03-10</publish_date>
    <description>In post-apocalypse England, the mysterious
    agent known only as Oberon helps to create a new life
    for the inhabitants of London. Sequel to Maeve
    Ascendant.</description>
    </book>



    Please help.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,234
    Rep Power
    19

    Default Re: xml file merging, based on the node.

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. How to split a file by based on size
    By kewlkeny in forum New To Java
    Replies: 3
    Last Post: 01-05-2012, 11:07 AM
  2. Replies: 1
    Last Post: 07-10-2010, 04:21 AM
  3. save file based on file extension
    By masa in forum AWT / Swing
    Replies: 4
    Last Post: 05-11-2010, 11:17 AM
  4. random node from an xml file
    By matthew.parse in forum New To Java
    Replies: 1
    Last Post: 04-13-2010, 08:45 PM
  5. Replies: 1
    Last Post: 07-14-2009, 05:06 PM

Posting Permissions

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