Wednesday, April 9, 2008

Native XML handling_6

Finally, ColdFusion can handle XML! If you've never heard of it before, XML stands for

eXtensible Markup Language, and it provides a way to structure data and encode it with

additional information using a plain text format that can be used by most modern application

servers and applications. Previously, data interchange with XML was limited to one of the

following two options in ColdFusion:

Use WDDX as an interchange format: This was a good start, but it was limited because

you were locked in to a data-centric flavor of XML. (WDDX is explained in detail in

Chapter 30.)

Use a COM object or third-part custom tag library: Some good libraries were on the

market, but they still are no match for the capability to natively use XML and XML

objects.

Now, by using ColdFusion MX, all you need do to create an XML object is use the new CFXML

tag, as follows:

<cfxml variable="XmlObj">

<my-xml-tag>

<my-child-tag />

</my-xml-tag>

</cfxml>

And that's only the beginning of an impressive array of XML handling features; in fact, the

only feature missing from ColdFusion's XML implementation is the capability to validate

against a DTD or XMLSchema document, which can be easily remedied by using COM. For

more information about validating XML with ColdFusion MX, see Chapter 29.

ColdFusion MX also natively handles XSLT transformations, so you can transform structured

XML documents into virtually any type of content. MX's XPath capabilities enable you to

query an XML object and extract data structures that match search criteria.

After you parse an XML document into an XML object, you can refer to its data elements by

using the same ColdFusion syntax used for handling arrays and structures, so your learning

curve remains relatively small.

0 comments: