You are previewing Beginning XML, 5th Edition.

Beginning XML, 5th Edition

Cover of Beginning XML, 5th Edition by Danny Ayers... Published by Wrox
  1. Cover
  2. Contents
  3. Part I: Introducing XML
    1. Chapter 1: What is XML?
      1. Steps Leading up to XML: Data Representation and Markups
      2. The Birth of XML
      3. More Advantages of XML
      4. XML in Practice
      5. Summary
    2. Chapter 2: Well-Formed XML
      1. What Does Well-Formed Mean?
      2. Creating XML in a Text Editor
      3. Advanced XML Parsing
      4. The XML Infoset
      5. Summary
    3. Chapter 3: XML Namespaces
      1. Defining Namespaces
      2. Why Do You Need Namespaces?
      3. How Do You Choose a Namespace?
      4. How to Declare a Namespace
      5. Namespace Usage in the Real World
      6. When to Use and Not Use Namespaces
      7. Common Namespaces
      8. Summary
  4. Part II: Validation
    1. Chapter 4: Document Type Definitions
      1. What Are Document Type Definitions?
      2. Anatomy of a DTD
      3. DTD Limitations
      4. Summary
    2. Chapter 5: XML Schemas
      1. Benefits of XML Schemas
      2. XML Schemas in Practice
      3. Defining XML Schemas
      4. Creating a Schema from Multiple Documents
      5. Documenting XML Schemas
      6. XML Schema 1.1
      7. Summary
    3. Chapter 6: Relax NG and Schematron
      1. Why Do You Need More Ways of Validating XML?
      2. Setting Up Your Environment
      3. Using RELAX NG
      4. Using Schematron
      5. Summary
  5. Part III: Processing
    1. Chapter 7: Extracting Data From XML
      1. Document Models: Representing XML in Memory
      2. The XPath Language
      3. Summary
    2. Chapter 8: XSLT
      1. What XSLT Is Used For
      2. Setting Up Your XSLT Development Environment
      3. Foundational XSLT Elements
      4. Reusing Code in XSLT
      5. Understanding Built-In Templates and Built-In Rules
      6. Using XSLT 2.0
      7. XSLT and XPath 3.0: What’s Coming Next?
      8. Summary
  6. Part IV: Databases
    1. Chapter 9: XQUERY
      1. XQuery, XPath, and XSLT
      2. XQuery in Practice
      3. Building Blocks of XQuery
      4. The Anatomy of a Query Expression
      5. Some Optional XQuery Features
      6. Coming in XQuery 3.0
      7. Summary
    2. Chapter 10: XML and Databases
      1. Understanding Why Databases Need to Handle XML
      2. Analyzing which XML Features are Needed in a Database
      3. Using MySQL with XML
      4. Using SQL Server with XML
      5. Using eXist with XML
      6. Summary
  7. Part V: Programming
    1. Chapter 11: Event-Driven Programming
      1. Understanding Sequential Processing
      2. Using SAX in Sequential Processing
      3. Using XmlReader
      4. Summary
    2. Chapter 12: LINQ to XML
      1. What Is LINQ?
      2. Creating Documents
      3. Extracting Data from an XML Document
      4. Modifying Documents
      5. Transforming Documents
      6. Using VB.NET XML Features
      7. Summary
  8. Part VI: Communication
    1. Chapter 13: RSS, ATOM, and Content Syndication
      1. Syndication
      2. Working with News Feeds
      3. A Simple Aggregator
      4. Transforming RSS with XSLT
      5. Useful Resources
      6. Summary
    2. Chapter 14: WEB Services
      1. What Is an RPC?
      2. RPC Protocols
      3. The New RPC Protocol: Web Services
      4. The Web Services Stack
      5. Summary
    3. Chapter 15: SOAP and WSDL
      1. Laying the Groundwork
      2. The New RPC Protocol: SOAP
      3. Defining Web Services: WSDL
      4. Summary
    4. Chapter 16: AJAX
      1. AJAX Overview
      2. Introduction to JavaScript
      3. The XMLHttpRequest Function
      4. Using HTTP Methods with AJAX
      5. Accessibility Considerations
      6. The jQuery Library
      7. JSON and AJAX
      8. The Web Sever Back End
      9. A Larger Example
      10. Summary
  9. Part VII: Display
    1. Chapter 17: XHTML and HTML 5
      1. Background of SGML
      2. The Open Web Platform
      3. Introduction to XHTML
      4. XHTML and HTML: Problems and Workarounds
      5. Cascading Style Sheets (CSS)
      6. Unobtrusive JavaScript
      7. HTML 5
      8. Summary
    2. Chapter 18: Scalable Vector Graphics (SVG)
      1. Scalable Vector Graphics and Bitmaps
      2. The SVG Graphics Model
      3. SVG and CSS
      4. SVG Tools
      5. SVG Basic Built-in Shapes
      6. SVG Transforms and Groups
      7. SVG Definitions and Metadata
      8. Viewports and Coordinates
      9. SVG Colors and Gradients
      10. Including Bitmap Images in SVG
      11. SVG Text and Fonts
      12. SVG Animation Four Ways
      13. SVG and HTML 5
      14. SVG and Web Apps
      15. Making SVG with XQuery or XSLT
      16. Resources
      17. Summary
  10. Part VIII: Case Study
    1. Chapter 19: Case Study: XML in Publishing
      1. Background
      2. Project Introduction: Current Workflow
      3. Introducing a New XML-Based Workflow
      4. Creating a New Process
      5. Some Technical Aspects
      6. The Hoy Books Website
      7. Summary
  11. Appendix A: Answers to Exercises
  12. Appendix B: XPath Functions
  13. Appendix C: XML Schema Data Types
  14. Introduction
  15. Advertisements

Chapter 11

Event-Driven Programming


  • Necessity of XML data access methods: SAX and .NET’s XMLReader
  • Why SAX and XMLReader are considered event-driven methods
  • How to use SAX and XMLReader
  • The right time to choose one of these methods to process your XML

There are many ways to extract information from an XML document. You’ve already seen how to use the document object model and XPath; both of these methods can be used to find any relevant item of data. Additionally, in Chapter 12 you’ll meet LINQ to XML, Microsoft’s latest attempt to incorporate XML data retrieval in its universal data access strategy.

Given the wide variety of methods already available, you may be wondering why you need more, and why in particular do you need event-driven methods? The main answer is because of memory limitations. Other XML processing methods require that the whole XML document be loaded into memory (that is, RAM) before any processing can take place. Because XML documents typically use up to four times more RAM than the size of the file containing the document, some documents can take up more RAM than is available on a computer; it is therefore necessary to find an alternative method to extract data. This is where event-driven paradigms come into play. Instead of loading the complete file into memory, the file is processed in sequence. There are two ways to do this: SAX and .NET’s XMLReader. Both are covered in this chapter.


The best content for your career. Discover unlimited learning on demand for around $1/day.