Results 1 to 3 of 3

Thread: Parsing XML

  1. #1
    techie is offline Member
    Join Date
    Dec 2010
    Posts
    1
    Rep Power
    0

    Default Parsing XML

    Hi All,

    I'm facing an issue while parsing the xml given below.

    <Transaction>
    <transEvent>
    <UserTest>usertest</UserTest>
    <Input>
    <Element1>
    Test1
    <Element2>elem</Element2>
    Test2
    </Element1>
    </Input>
    </transEvent>
    </Transaction>

    In the above example, the Element1 node has text content 'Test1' followed by a child node Element2 and then text 'Test2'.

    I'm using SAX parser to parse the xml and obtain a node(HashNode) representation of the xml to regenerate the message later.
    The problem I'm facing is while setting the value for the Element1.
    the Element1 node takes only one value, so the value is getting replaced.

    I don't want to use DOM parser as it's a small xml file and there might be performance issues.

    Also, I want to make sure that the order of the nodes is not affected. i.e Test1 followed by Element2 and then Test2.

    Can anyone please guide me?
    Thanks

  2. #2
    rauff is offline Member
    Join Date
    May 2010
    Posts
    8
    Rep Power
    0

    Default

    Try to use XPath component :)
    Check this tutorial in roseindia


    www.juragandesign.com

  3. #3
    munish is offline Member
    Join Date
    Jul 2009
    Posts
    37
    Rep Power
    0

    Default

    you can use dom xml parser there is no question of any performance issues it is best for small as well as for large xml files.
    Last edited by munish; 02-07-2011 at 10:07 AM.

Similar Threads

  1. Parsing
    By Matt Sakko in forum New To Java
    Replies: 14
    Last Post: 03-21-2009, 05:49 PM
  2. Xml Parsing
    By Nomad in forum XML
    Replies: 12
    Last Post: 02-22-2009, 12:19 PM
  3. xml parsing help
    By tankhardrive in forum XML
    Replies: 2
    Last Post: 02-12-2009, 12:45 AM
  4. xml parsing
    By gaurav65176 in forum XML
    Replies: 5
    Last Post: 11-12-2008, 12:07 PM
  5. Parsing URL
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-26-2007, 11:16 AM

Posting Permissions

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