How to get sub XML structure snippet from a big XML

Discussions

XML & Web services: How to get sub XML structure snippet from a big XML

  1. Hello Gurus,

    How to get sub XML structure snippet from a big XML file

    Ex:
    <Info>
         <person>
    <address>
    <street>
    <name>
    <type>
    </street>
    </address>
         </person>
    <CCard>
    <cardno>23232323232323</cardno>
    < expire>9/09</expire>
         </CCard>
    <>
    .
    .
    .
    .
    .
    .
    </>
    <>
    .
    .
    </>
    </Info>

    I want to get the XML snippet of address only, I don’t want to use String tokenizer, Is there any way to get it?
    I will really appreciate your help.


    Thanks
    Buchanna Gajula
  2. You can use XQuery to get this. There are various XQuery libs available and if u are using weblogic workshop, it is very easy. You can diagramatically design ur query. If u dont want to use that, u can compile the schema for this XML into apache xml beans and use the getAddress() on the appropriate bean to get the address. Never use StringTokenizer because it can cause all other headaches like decoding the < and other escape chars.

    Hope it helps