Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Reading elements by name only.

843834Apr 8 2002 — edited Apr 8 2002
I'm fairly new to java and xml, and tend to think of XML datasets as recordsets (which may be inaccurate). I have an XML string that contains stock quotes, for example, and I want to iterate through this XML document using JSP and output the symbol and the last-trade-price.

<?xml version=\"1.0\"?>
<stock-quotes>
<stock-quote>
<last-trade-price>30.37100000</last-trade-price>
<net-change>0.50100000</net-change>
<daily-vol>10182600</daily-vol>
<quote-bid-price-exch>30.37000000</quote-bid-price-exch>
<quote-ask-price-exch>30.38000000</quote-ask-price-exch>
<sec-company-name>INTEL CORP</sec-company-name>
<symbol>INTC</symbol>
</stock-quote>
</stock-quotes>

Once I have the document object, I want to do conceptually something like....


for each stock-quote in myDoc
out.print(symbol + ": " + last-trade-price + "<BR>");
next

Is there an easy way to do this? I'm not finding anything that really allows me to treat this XML object like a recordset, or even a nested recordset, where you sort of step through it like you would with a RS.MoveNext.

Thanks.
Eric.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 6 2002
Added on Apr 8 2002
3 comments
91 views