XmlHasChild

Description

Checks if the XML document object has a child node.

Returns

True if a child node exists. False, otherwise.

Category

XML functions

Syntax

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

Parameters

Parameter Description
xmlObject The XML document object to be checked for child nodes.
childName The 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

 Adobe

Получайте помощь быстрее и проще

Новый пользователь?