Results 1 to 2 of 2
  1. #1
    berkeleybross's Avatar
    berkeleybross is offline Senior Member
    Join Date
    Feb 2010
    Location
    England
    Posts
    187
    Rep Power
    5

    Default Socket XML Parser

    Hi,

    I need to be able to parse XML recieved from a socket. Every socket.readLine makes a complete XML (document?) (A sample is provided below).

    All the XML parsers I've found so far seem to be for reading XML files with close document tags etc.

    Im new to java and XML so if you could explain it simply for me, Id much appreciate it. Failing that, could you point me in the direction of a decent tutorial for beginners, all the ones i've googled have gone straight over my head :$

    Thanks in advance!


    <ns0:DBGMMessage xmlns:ns1="DbGMLCashflowCollection/Party" SchemaVersion="1.0">
    <BusinessHdr><ns4:BusObjectType xmlns:ns4="DbGMLCashflowCollection/BusHdr">CASHF
    LOWCOLLECTION/VALUETODAY</ns4:BusObjectType><ns4:BusObjectId xmlns:ns4="DbGMLCas
    hflowCollection/BusHdr">20091224ET041299</ns4:BusObjectId><ns4:BusEventTimeStamp
    xmlns:ns4="DbGMLCashflowCollection/BusHdr">2009-04-20T00:24:06.038+01:00</ns4:B
    usEventTimeStamp><ns4:SchemaVersion xmlns:ns4="DbGMLCashflowCollection/BusHdr">1
    .0</ns4:SchemaVersion></BusinessHdr><CashflowCollection><CashflowCollectio nId>ET
    041299/2009-06-22/JPY</CashflowCollectionId><CashflowCollectionVersion>1</Cashfl
    owCollectionVersion><Parties><LegalEntity>ENTITY</LegalEntity><BusinessGroup>OTC
    _TOK</BusinessGroup><GsdId>GREENSECUTOK</GsdId></Parties><Cashflow><CashflowId>7
    </CashflowId><CashflowVersion>1</CashflowVersion><ValueDate>2</ValueDate><Notion
    al><Currency>KRW</Currency><Amount>5650000</Amount></Notional><Amount><Currency>
    KRW</Currency><Amount>-1441000</Amount></Amount><CashflowType>COUPON</CashflowTy
    pe><FeeType>OTHER</FeeType><RateIndex><IndexName>LIBOR</IndexName><IndexTenor>A3
    60</IndexTenor></RateIndex><StreamId>0</StreamId><RefixDate>2008-12-18Z</RefixDa
    te><RefixRate>1.0425</RefixRate></Cashflow><Cashflow><CashflowId>7</CashflowId><
    CashflowVersion>1</CashflowVersion><ValueDate>2</ValueDate><Notional><Currency>K
    RW</Currency><Amount>5650000</Amount></Notional><Amount><Currency>KRW</Currency>
    <Amount>1249000</Amount></Amount><CashflowType>COUPON</CashflowType><FeeType>OTH
    ER</FeeType><RateIndex><IndexName>FIXED</IndexName><IndexTenor>A360</IndexTenor>
    </RateIndex><StreamId>0</StreamId><RefixDate>2008-12-18Z</RefixDate><RefixRate>1
    .04</RefixRate></Cashflow><Context><BusinessObjId>T182478L</BusinessObjId><Produ
    ct><ProductGroup>SWAP</ProductGroup><ProductType>SWAP</ProductType><Features>VAN
    ILLA</Features></Product><BookId>YAG_SWAPS</BookId><TradeDate>2004-06-18</TradeD
    ate><MaturityDate>2024-06-24</MaturityDate><EffectiveDate>2009-12-24</EffectiveD
    ate><TradeId>ET041299</TradeId></Context></CashflowCollection></ns0:DBGMMessage>

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,842
    Rep Power
    19

    Default

    Just a quick format of that:

    Java Code:
    <ns0:DBGMMessage xmlns:ns1="DbGMLCashflowCollection/Party" SchemaVersion="1.0">
        <BusinessHdr>
            <ns4:BusObjectType xmlns:ns4="DbGMLCashflowCollection/BusHdr">CASHFLOWCOLLECTION/VALUETODAY</ns4:BusObjectType>
            <ns4:BusObjectId xmlns:ns4="DbGMLCashflowCollection/BusHdr">20091224ET041299</ns4:BusObjectId>
            <ns4:BusEventTimeStamp xmlns:ns4="DbGMLCashflowCollection/BusHdr">2009-04-20T00:24:06.038+01:00</ns4:BusEventTimeStamp>
            <ns4:SchemaVersion xmlns:ns4="DbGMLCashflowCollection/BusHdr">1.0</ns4:SchemaVersion>
        </BusinessHdr>
        <CashflowCollection>
            <CashflowCollectionId>ET041299/2009-06-22/JPY</CashflowCollectionId>
            <CashflowCollectionVersion>1</CashflowCollectionVersion>
            <Parties>
                <LegalEntity>ENTITY</LegalEntity>
                <BusinessGroup>OTC_TOK</BusinessGroup>
                <GsdId>GREENSECUTOK</GsdId>
            </Parties>
            <Cashflow>
                <CashflowId>7</CashflowId>
                <CashflowVersion>1</CashflowVersion>
                <ValueDate>2</ValueDate>
                <Notional>
                    <Currency>KRW</Currency>
                    <Amount>5650000</Amount>
                </Notional>
                <Amount>
                    <Currency>KRW</Currency>
                    <Amount>-1441000</Amount>
                </Amount>
                <CashflowType>COUPON</CashflowType>
                <FeeType>OTHER</FeeType>
                <RateIndex>
                    <IndexName>LIBOR</IndexName>
                    <IndexTenor>A360</IndexTenor>
                </RateIndex>
                <StreamId>0</StreamId>
                <RefixDate>2008-12-18Z</RefixDate>
                <RefixRate>1.0425</RefixRate>
            </Cashflow>
            <Cashflow>
                <CashflowId>7</CashflowId>
                <CashflowVersion>1</CashflowVersion>
                <ValueDate>2</ValueDate>
                <Notional>
                    <Currency>KRW</Currency>
                    <Amount>5650000</Amount>
                </Notional>
                <Amount>
                    <Currency>KRW</Currency>
                    <Amount>1249000</Amount>
                </Amount>
                <CashflowType>COUPON</CashflowType>
                <FeeType>OTHER</FeeType>
                <RateIndex>
                    <IndexName>FIXED</IndexName>
                    <IndexTenor>A360</IndexTenor>
                </RateIndex>
                <StreamId>0</StreamId>
                <RefixDate>2008-12-18Z</RefixDate>
                <RefixRate>1.04</RefixRate>
            </Cashflow>
            <Context>
                <BusinessObjId>T182478L</BusinessObjId>
                <Product>
                    <ProductGroup>SWAP</ProductGroup>
                    <ProductType>SWAP</ProductType>
                    <Features>VANILLA</Features>
                </Product>
                <BookId>YAG_SWAPS</BookId>
                <TradeDate>2004-06-18</TradeDate>
                <MaturityDate>2024-06-24</MaturityDate>
                <EffectiveDate>2009-12-24</EffectiveDate>
                <TradeId>ET041299</TradeId>
            </Context>
        </CashflowCollection>
    </ns0:DBGMMessage>
    Have a look at w3schools for a tutorial on XML. But that there is valid XML, except I would ask what ns0 is, and why ns1 is declared but not used?

Similar Threads

  1. append response to the request from Socket and write to another socket
    By vaibhav_singh_vs@yahoo.co in forum Networking
    Replies: 3
    Last Post: 04-17-2009, 07:02 PM
  2. Parser API
    By sruti_mohan in forum Advanced Java
    Replies: 0
    Last Post: 06-09-2008, 07:23 AM
  3. JSP Parser????
    By chathu03j in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 04-10-2008, 12:08 PM
  4. DNS name parser 1.2.1
    By JavaBean in forum Java Software
    Replies: 0
    Last Post: 07-14-2007, 08:21 PM
  5. Parser
    By Peter in forum Advanced Java
    Replies: 2
    Last Post: 07-04-2007, 07:08 AM

Tags for this Thread

Posting Permissions

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