View comments | RSS feed
Contents > CFML Reference > ColdFusion Functions > XmlChildPos PreviousNext

XmlChildPos

Gets the position of a child element within an XML document object.

The position, in an XmlChildren array, of the Nth child that has the specified name.

Extensibility functions, XML functions

XmlChildPos(elem, childName, N) 

cfxml, IsXmlDoc, XmlChildPos, XmlFormat, XmlNew, XmlParse, XmlSearch, XmlTransform

ColdFusion MX: Added this function.

Parameter

Description

elem

XML element within which to search

childName

XML child element for which to search

N

Index of XMLchild element for which to search

The returned index can be used in the ArrayInsertAt and ArrayDeleteAt functions.

This example searches the XML document object mydoc.employee.XmlChildren for the mydoc.employee.name[2] element:

XmlChildPos(mydoc.employee, "name", 2) 

Contents > CFML Reference > ColdFusion Functions > XmlChildPos PreviousNext

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.

Comments


Adam Cameron said on Jan 12, 2005 at 12:06 PM :
I didn't quite get what this funciton was all about initially, and others might suffer from the same problem (or maybe I'm just dumb).

This example illustrates the function more clearly:


<cfxml variable="x">
<fruit>
<apple>green</apple>
<banana>yellow</banana>
<cherry>purple</cherry>
<cherry>red</cherry>
<cherry>yellow</cherry>
<apple>red</apple>
</fruit>
</cfxml>
<cfdump var="#x#">
<cfset i = xmlChildPos(x.fruit, "apple", 2)>
<cfdump var="#i#" label="The second 'apple' is the 6th node within
'fruit'">
tredychris said on Sep 12, 2005 at 2:07 PM :
How in Adams example can you find the childpostion of the second apple if you only know its a "red" apple ??

regards
Chris

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/funca121.htm