Home > Articles > Web Services > XML

  • Print
  • + Share This
This chapter is from the book

Querying XML Elements Using XPath

The previous section "XML as a Wire Representation" provides you with a few reasons why we've seen explosive growth of XML in the past few years, and it told why XML was selected to be a major component of the SOAP protocol. Another factor is the many peripheral XML technologies that make using XML even more attractive. Certainly one of these technologies is XPath, which is the language that you use to query an XML document for specific information.

If you work with XML, you're probably somewhat familiar with XPath. If not, here is the basic idea. XPath serves the same purpose as the Structured Query Language (SQL) for database access. With SQL, you establish a search expression and provide that to the database. The database, in turn, searches its tables for the data that you requested and provides you with the results. XPath also establishes search patterns, but instead of accessing a database, you apply the XPath query against an XML document that is contained within an XML processor.

XML processors are software components that, when provided an XML document, expose a programmable interface that enables you to work with the XML document in an automated manner. Typically XML processors expose the XML Document Object Model (DOM) or perhaps the Simple API for XML (SAX). The DOM enables you to deal with the XML document as if it were composed of tree nodes. SAX, on the other hand, offers a stream-based approach to accessing the XML information. You take what you need from the stream and discard the rest. (.NET implements another model that you'll examine in the later section ".NET's XML Architecture.")

Because this book is focused on Web Services, we won't go into much detail regarding DOM or SAX, which are general XML topics that merit their own book. If you need a brush-up, or if XML is new to you, I'll explain the basics here. For more information, see the references included in Appendix D.

  • + Share This
  • 🔖 Save To Your Account