Adobe ColdFusion 8

IsXmlNode

Description

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

Returns

True, if the function argument is an XML document object node, including an element; False, otherwise.

Category

Decision functions, XML functions

Function syntax

IsXmlNode(value)

See also

IsXML, IsXmlAttribute, IsXmlDoc, IsXmlElem, IsXmlRoot, XmlGetNodeType, XmlSearch, XmlValidate; "Using XML and WDDX" in the ColdFusion Developer's Guide

History

ColdFusion MX 7: Added this function.

Parameters

Parameter

Description

value

Name of an XML document object node.

Usage

This function returns True for the following components of an XML document object:

  • The document object
  • Elements in the object
  • XmlNode objects in an element's XmlNodes array

It also returns True for XML node objects returned by the XmlSearch function. It does not return True for most entries in an element, including XmlText, XmlComment, XmlCdata, or the XmlAttributes array (or individual XML attributes).

Example

The following example tests whether an XML document object, an element, an attribute in the object, and an attribute returned by an XmlSearch function are nodes:

<!--- Create an XML document object --->
<cfxml variable="xmlobject">
<?xml version="1.0" encoding="UTF-8"?>
<order id="4323251">
    <customer firstname="Philip" lastname="Cramer" accountNum="21"/>
    <items>
        <item id="43">
            <quantity>1</quantity>
            <unitprice>15.95</unitprice>
        </item>
    </items>
</order>
</cfxml>

<!--- use XmlSearch to get an attribute node. --->
<cfset lastnames = XmlSearch(xmlobject, '//@lastname')>

<!--- Test the objects to see if they are XML nodes--->
<cfoutput>
<h3>Are the following XML nodes?</h3>
xmlobject: #IsXmlNode(xmlobject)#<br>
<!--- The items element --->
xmlobject.order.items: #IsXmlNode(xmlobject.order.items)#<br>
<!--- The order element id attribute; a simple variable, not a DOM node.--->
xmlobject.order.XmlAttributes.id: 
    #IsXmlNode(xmlobject.order.XmlAttributes.id)#<br>
lastnames[1] returned by XmlSearch: 
#isXmlNode(lastnames[1])#
</cfoutput>