Importing and Reading XML
JavaScript's ability to deal with XML is currently limited. Right now, only IE5+ browsers on Windows machines can import XML files and allow JavaScript to deal with them. Hopefully, by the time you read this, the various browsers will have evolved enough so that both Netscape and IE on both Mac and Windows will be able to import and read XML.
First, let's look at Example 18-1, the XML document we'll be importing and parsing. It's an order from a clothing boutique, buying a set of clothes from a wholesaler.
Example 18-1. stitch.xml
<?xml version="1.0" ?> <order> <shirts> <shirt quantity="4"> <size>XXL</size> <color>purple</color> </shirt> <shirt quantity="1"> <size>M</size> <color>red</color> </shirt> </shirts> <sweatshirts> ... |
Get Advanced JavaScript™: Insights and Innovative Techniques now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.