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
O'Reilly logo

Chapter 7

Extracting Data from XML

WHAT YOU WILL LEARN IN THIS CHAPTER:

  • How XML is usually represented in memory
  • What the DOW and the XDM are
  • What XPath is
  • How to read and write XPath expressions
  • How to learn more about the XPath language when you need it

There’s quite a lot packed into a small space here, but XPath is both important and useful. Most useful languages for querying and extracting data have fairly powerful expression languages and XPath is no exception. It’s everywhere, too: XPath “engines” are available for pretty much every programming environment, from JavaScript to Java, from PHP and Perl to Python, from C to SQL. XPath is also central to XSLT and XQuery.

DOCUMENT MODELS: REPRESENTING XML IN MEMORY

XML is a text-based way to represent documents, but once an XML document has been read into memory, it’s usually represented as a tree. To make developers’ lives easier, several standard ways exist to represent and access that tree. All of these ways have differences in implementation, but once you have seen a couple, the others will generally seem very similar.

This chapter briefly introduces three of the most widely used models; you learn more about each of them later in the book. You also learn how to avoid using these data models altogether using XPath (in this chapter) and XQuery (in Chapter 9).

Meet the Models: DOM, XDM, and PSVI

The best-known data model for storing and processing XML trees is called the W3C document object model, or the DOM for short. The ...

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