ColdFusion XML tag and functions

The following table lists the ColdFusion tags and functions that create and manipulate XML documents:

Tag or function

Description

<cfxml variable="objectName"

[caseSensitive="Boolean"]>

Creates a ColdFusion XML document object consisting of the markup in the tag body. The tag can include XML and CFML tags. ColdFusion processes all CFML in the tag body before converting the resulting text to an XML document object.

If you specify the CaseSensitive="True" attribute, the case of names of elements and attributes in the document is meaningful. The default value is False.

For more information on using the cfxml tag, see Creating an XML document object using the cfxml tag.

XmlParse (XMLText

[[, caseSensitive],

validator])

Converts an XML document in a file or a string variable into an XML document object, and optionally validates the document against a DTD or schema.

If you specify the optional second argument as True, the case of names of elements and attributes in the document is meaningful. The default value is False.

For more information on using the XmlParse function, see Creating an XML document object from existing XML.

XmlNew([caseSensitive])

Returns an empty XML document object.

If you specify the optional argument as True, the case of names of elements and attributes in the document is meaningful. The default value is False.

For more information on using the XmlNew function, see Creating an XML document object using the XmlNew function.

XmlElemNew(objectName{,

namespaceURI],

elementName)

Returns an XML document object element with the specified name, optionally belonging to the specified namespace. You can omit the namespaceURI parameter and use only a namespace prefix if the prefix is defined elsewhere in the object.

For more information on using theXmlElemNew function, see Adding an element.

XmlTransform(XMLVar,

XSLTStringVar[,

parameters])

Applies an Extensible Stylesheet Language Transformation (XSLT) to an XML document. The document can be represented as a string variable or as an XML document object. The function returns the resulting XML document as a string.

For more information on using theXmlTransform function, see Transforming documents with XSLT.

XmlSearch(objectName,

XPathExpression)

Uses an XPath expression to search an XML document object and returns an array of XML elements that match the search criteria.

For more information on using the XmlSearch function, see Extracting data with XPath.

XmlValidate(xmlDoc[,

validator])

Uses a Document Type Definition (DTD) or XML Schema to validate an XML text document (in a string or file) or an XML document object. The validator can be a DTD or Schema. If you omit the validator parameter, the document must specify a DTD or schema. For more information on using the XmlValidate function, see Validating XML documents

XmlChildPos(element,

elementName, position)

Returns the position (index) in an XmlChildren array of the Nth child with the specified element name. For example, XmlChildPos(mydoc.employee, "name", 2) returns the position in mydoc.employee.XmlChildren of the mydoc.employee.name[2] element. This index can be used in the ArrayInsertAt and ArrayDeleteAt functions.

For more information on using theXmlChildPos function, see Determining the position of a child element with a common name, Adding an element, and Deleting elements.

XmlGetNodeType(xmlNode)

Returns a string identifying the type of an XML document object node returned by the function or in an element’s XmlNodes array.

IsWDDX(String)

Determines whether a string is a well-formed WDDX packet.

IsXML(String)

Determines whether a string is well-formed XML text.

IsXmlAttribute(variable)

Determines whether the function parameter is an XML Document Object Model (DOM) attribute node.

IsXmlDoc(objectName)

Returns True if the function argument is an XML document object.

IsXmlElem(elementName)

Returns True if the function argument is an XML document object element.

IsXmlNode(variable)

Determines whether the function parameter is an XML document object node.

IsXmlRoot(elementName)

Returns True if the function argument is the root element of an XML document object.

ToString(objectName)

Converts an XML document object to a string representation.

XmlFormat(string)

Escapes special XML characters in a string so that the string can be used as text in XML.

About case sensitivity and XML document objects

The tags and functions that create XML document objects let you specify whether ColdFusion treats the object in a case-sensitive manner. If you do not specify case sensitivity, ColdFusion ignores the case of XML document object component identifiers, such as element and attribute names. If you do specify case sensitivity, names with different cases specify different components. For example, if you do not specify case sensitivity, the names mydoc.employee.name[1] and mydoc.employee.NAME[1] always specify the same element. If you specify case sensitivity, these names specify two separate elements. You cannot use dot notation references for element or attribute names in a case-sensitive XML document; for more information see Referencing the contents of an XML object.