Whatever message this page gives is out now! Go check it out!

IsXmlAttribute

Last update:
May 18, 2026

Description

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

Returns

True, if the function argument is an XML attribute node; False, otherwise.

Category

Function syntax

IsXmlAttribute(value)

See also

IsXMLIsXmlDocIsXmlElemIsXmlNodeIsXmlRootXmlGetNodeTypeXmlValidateUsing XML and WDDX in the Developing ColdFusion Applications

History

ColdFusion MX 7: Added this function.

Parameters

Parameter
Description
value
Name of an XML attribute

Usage

This function determines whether the parameter is an XML DOM attribute node, a node with an XMLType value of ATTRIBUTE. It is useful for determining whether a value returned by the XmlSearch function is an XML attribute. The DOM, and therefore ColdFusion, treats XML attributes as properties of an element and does not directly expose them as DOM nodes. For this reason, the XmlAttributes entries in ColdFusion XML document objects do not represent DOM attribute nodes, and tests such as the following always return False:
IsXmlAttribute(myxmlelement.XMlAttributes); 
IsXmlAttribute(myxmlelement.XMlAttributes.myattribute);
The XmlSearch function does return attributes as XML DOM attribute nodes. For example, the following line returns an array of attribute nodes containing the quantity attributes in the xmlobject document object:
quantities = XmlSearch(xmlobject, '//@quantity');
Example
The following example creates an XML document object and gets parts of it. It then tests whether these parts are attribute nodes.
<!--- Create an XML document object ---> 
<cfxml variable="xmlobject"> 
<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> 

<!--- Get an array with all lastname quantity DOM attribute nodes 
(In this example there is only one entry) ---> 
<cfset lastnames = XmlSearch(xmlobject, '//@lastname')> 

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

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page