Processing XML

XML is so popular that web browsers have built-in mechanisms for dealing with XML documents. In fact, all of the methods used to process the DOM (discussed in Chapter 13) can also be used to process XML documents.

The script in Figure 15-6 shows how to use some of the methods that we used to process the DOM to create an application that looks up a word in three dictionary files (German, Portuguese, and Italian), which I downloaded from the Internet Dictionary Project (http://www.ilovelanguages.com/IDP).

Reading an XML document

Figure 15-6. Reading an XML document

As you can see in Figure 15-7, entering aardvark into the text box and clicking the Translate! ...

Get The Book of JavaScript, 2nd Edition 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.