1、 -1- 外文原文 Chapter 3. Parsing XML With two solid chapters of introduction behind us, we are ready to code! By now you have seen the numerous acronyms that make up the world of XML, you have delved into the language itself, and you should be familiar with an XML document. This chapter takes the next s
2、tep, and the first on our path of Java programming, by demonstrating how an XML document is parsed and how we can access the parsed data from within Java code. One of the first things you will have to do when dealing with XML programmatically is take an XML document and parse it. As the document is
3、parsed, the data in the document becomes available to the application using the parser, and suddenly we are within an XML-aware application! If this all sounds a little too simple to be true, it almost is. In this chapter, we will look closely at how an XML document is parsed. Using a parser within
4、an application and how to feed that parser your documents data will be covered. Then we will look at the various callbacks that are available within the parsing lifecycle. These events are the points where application-specific code can be inserted and data manipulation can occur. In addition to looking at how parsers work, we will also begin our exploration of the Simple API for XML (SAX) in this chapter. SAX is what makes these parsing callbacks available. The interfaces provided in the SAX