Parsing XML Yourself
Say that you have this XML document, ch01_02.xml, which we developed earlier in this chapter:
<?xml version="1.0" encoding="UTF-8"?> <DOCUMENT> <GREETING> Hello From XML </GREETING> <MESSAGE> Welcome to the wild and woolly world of XML. </MESSAGE> </DOCUMENT>
Now say that you wanted to extract the greeting Hello From XML from this XML document. One way of doing that is by using XML data islands in Internet Explorer and then using a scripting language, such as JavaScript, to extract and display the text content of the <GREETING> element. Here's how that looks in a Web page:
Listing . ch01_08.html
<HTML> <HEAD> <TITLE> Finding Element Values in an XML Document </TITLE> <XML ID="firstXML" SRC="ch01_02.xml"></XML> <SCRIPT ... |
Get Real World XML 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.