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

XmlHasChild

Last update:
May 18, 2026

Description

Checks if the XML document object has a child node.

Returns

True if a child node exists. False, otherwise.

Category

Syntax

XmlHasChild(xmlObject)
XmlHasChild(xmlObject [, childName])

Parameters

ParameterDescription
xmlObjectThe XML document object to be checked for child nodes.
childNameThe name of the child node to check if it exists.

Example 1

<cfxml variable="xmlData">
  <root>
    <item id="1">Item 1</item>
    <item id="2">Item 2</item>
    <item id="3">Item 3</item>
  </root>
</cfxml>

<cfscript>
    writeDump(xmlData)
    writeOutput("<br/>")
    writeOutput(xmlHasChild(xmlData)) // YES
</cfscript>

Try in CFFiddle

Example 2

<cfxml variable="xmlData">
  <root>
    <item id="1">Item 1</item>
    <item id="2">Item 2</item>
    <item id="3">Item 3</item>
  </root>
</cfxml>

<cfscript>
    writeDump(xmlData)
    writeOutput("<br/>")
    writeOutput(xmlHasChild(xmlData,"root")) // YES
    writeOutput("<br/>")
    writeOutput(xmlHasChild(xmlData,"item")) // NO
</cfscript>

Try in CFFiddle

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