CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Threaded View

  1. #1
    Join Date
    Oct 2003
    Posts
    20

    How do you continue parsing even when expected elements are missing from xml file

    Hi,

    I have an XML file that can have a varying structure. For example in the chunk below the <subtrade> element has a subelement called <creditCurveFull>. However, <creditCurveFull> may be missing from the next <subtrade> element and reappear in the next <subtrade> element and so on.

    Currently, my code just bombs out if it does not see the element that it is expecting to parse i.e. <creditCurveFull>. How do I deal with this so that my code continues to parse the rest of the document even if the elements that it is expecting to see are missing?

    code is attached.

    xml chunk
    -----------

    <book>
    <riskGroup>GCPIG</riskGroup>
    <summitBook>GCPIG</summitBook>
    <desk>GCP_LN</desk>
    - <counterparty>
    <cptyId>DB-LN-CDTLEM</cptyId>
    <cptyIdLong>Deutsche Bank AG, London</cptyIdLong>
    - <trade>
    <tradeId>C414287M</tradeId>
    - <subtrade>
    <primitiveTrade>1</primitiveTrade>
    <analyticsProductType>DEFAULTSWAP</analyticsProductType>
    <assetClass>BUCOMK</assetClass>
    <ccy>USD</ccy>
    <maturityDate>2004-03-19</maturityDate>
    <effectiveDate>2003-03-19</effectiveDate>
    <tradeDate>2003-03-19</tradeDate>
    <notional>2000000.00</notional>
    <notionalCurrency>USD</notionalCurrency>
    <creditCurveFull>BUMIPUTRA COMMERCE BANK BHD</creditCurveFull>
    <countryOfIssuer>Malaysia</countryOfIssuer>
    <sector>BANKING</sector>
    <buySell>S</buySell>
    <interestRate>0.0065</interestRate>
    <productType>DEFSWAP</productType>
    <payFreq>Quarterly</payFreq>
    - <reportcollection>
    - <report>
    <reportName>PRICE_CARRY_TODAY</reportName>
    - <riskPoint>
    <value>-4952.002523</value>
    </riskPoint>
    </report>
    </reportcollection>
    </subtrade>
    </trade>
    </counterparty>
    Attached Files Attached Files

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured