User Guide

Table Of Contents
843
CHAPTER 35
Using XML and WDDX
This chapter describes how to use Macromedia ColdFusion MX to create, use, and manipulate
XML documents. This chapter also presents Web Distributed Data Exchange (WDDX), an XML
dialect for transmitting structured data, and describes how to use it to transfer data between
applications and between CFML and JavaScript.
This chapter does not present XML concepts. Before you read this chapter you should become
familiar with XML.
Contents
About XML and ColdFusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 843
The XML document object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 844
ColdFusion XML tag and functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 850
Using an XML object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 852
Creating and saving an XML document object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 856
Modifying a ColdFusion XML object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 858
Validating XML documents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 868
Transforming documents with XSLT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 869
Extracting data with XPath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 869
Example: using XML in a ColdFusion application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 870
Moving complex data across the web with WDDX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 875
Using WDDX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 879
About XML and ColdFusion
In the last few years, XML has rapidly become the universal language for representing documents
and data on the web. These documents can extend beyond the traditional concept of a paper
document or its equivalent. For example, XML is often used to represent database or directory
information. XML is also commonly used to represent transaction information, such as product
orders or receipts, and for information such as inventory records and employee data.