I don't know if this will help, but I added a new "child" element with
no "value" attribute. I modded my xPath to allow for this by only
returning "child" elements that contain the "value" attribute.
The first dump shows only elements that contain a "value" attribute.
The second dumpe shows all element that may or may not contain a "value"
attribute.
I checked www.w3schools.com for more information, but I can't find
exactly what you are asking.
Thanks
M!ke Dawson
<cfxml variable="myXML">
<parent>
<child name="jo">
<weight value="100lbs"/>
</child>
<child name="mike">
<weight value="180lbs"/>
</child>
<child name="hildegard">
<weight unknown="true" />
</child>
</parent>
</cfxml>
<cfset xPath = "/parent/child/[EMAIL PROTECTED]">
<cfset xSearch = XMLSearch(myXML, xPath)>
<p><cfdump var="#xSearch#" label="xSearch for specific attribute
value"></p>
<cfset xPath = "/parent/child/weight">
<cfset xSearch = XMLSearch(myXML, xPath)>
<p><cfdump var="#xSearch#" label="xSearch for all weight elements"></p>
<p>Loop over returned elements<br>
<cfloop from="1" to="#ArrayLen(xSearch)#" index="ii">
<cfif StructKeyExists(xSearch[ii].xmlAttributes, "value")>
<cfoutput>#xSearch[ii].xmlAttributes.value#</cfoutput><br>
<cfelse>
Attribute not found<br>
</cfif>
</cfloop>
</p>
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Justin Balog
Sent: Tuesday, February 03, 2004 2:54 PM
To: '[EMAIL PROTECTED]'
Subject: [CFCDev] OT: XPath() and getting attributes
Would an XPathQueryString look like to find the attributes of an XML
tag?
Basically, is it possible to return the value attribute of the weight
tag, or does xmlSearch() only return the text elements?
<parent>
<child name="jo">
<weight value="100lbs"/>
</child>
</parent>
Thanks,
Justin
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool,
Corporation (www.mindtool.com).
An archive of the CFCDev list is available at
www.mail-archive.com/[EMAIL PROTECTED]
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]