O'Reilly logo

XML and Java™ from scratch by Nicholas Chase

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Manipulating In-Memory Documents

Now that we've created an order, we need to give the user a way to review the items that have been added to it. Our algorithm for doing that might look something like this:

Check for an existing order
If the order exists, display information on each item:
    Get the order item
    Retrieve information on the item from products.xml
    Display the information on that item
Else
    Display a message that there is no current order

Let's think about how we want to do this. Looking at the orders.xml file, a typical order might look similar to this:

 <order order_id="To1010mC7161452772864825At"> <order_status>open</order_status> <item product_id="RC2342"> <quantity>3</quantity> </item> <item product_id="QA3452"> <quantity>1</quantity> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required