Java Xml Parsing :Distinguish two Xml Elements by missing tag



From a Webserver request i get an XML Response,which contains my needed data. it looks like (excerpt):



<ctc:BasePrice>
<cgc:PriceAmount amountCurrencyID="EUR">18.75</cbc:PriceAmount>
<cgc:BaseQuantity quantityUnitCode="EA">1</cbc:BaseQuantity>
</cac:BasePrice>
<ctc:BasePrice>
<cgc:PriceAmount amountCurrencyID="EUR">18.25</cbc:PriceAmount>
<cgc:BaseQuantity quantityUnitCode="EA">1</cbc:BaseQuantity>
<cgc:MinimumQuantity quantityUnitCode="EA">3</cbc:MinimumQuantity>
<ctc:BasePrice>


What i need is the first "PriceAmount" value,which could be a different price then the second. But how can i make sure to retrieve the correct one,by "telling" the parser he should take the element which does not contain the "MinimumQuantity" Field and distinguish them ? I read a lot in Sax etc but could find an idea how to implement a "logic" for that. Maybe someone ran into similar problem.Thanks in advance for every hint.


No comments:

Post a Comment