-
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>
-
Just a quick format of that:
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?