Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
21
Task/XML-XPath/ColdFusion/xml-xpath.cfm
Normal file
21
Task/XML-XPath/ColdFusion/xml-xpath.cfm
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<cfsavecontent variable="xmlString">
|
||||
<inventory
|
||||
...
|
||||
</inventory>
|
||||
</cfsavecontent>
|
||||
<cfset xml = xmlParse(xmlString)>
|
||||
<!--- First Task --->
|
||||
<cfset itemSearch = xmlSearch(xml, "//item")>
|
||||
<!--- item = the first Item (xml element object) --->
|
||||
<cfset item = itemSearch[1]>
|
||||
<!--- Second Task --->
|
||||
<cfset priceSearch = xmlSearch(xml, "//price")>
|
||||
<!--- loop and print each price --->
|
||||
<cfloop from="1" to="#arrayLen(priceSearch)#" index="i">
|
||||
#priceSearch[i].xmlText#<br/>
|
||||
</cfloop>
|
||||
<!--- Third Task --->
|
||||
<!--- array of all the name elements --->
|
||||
<cfset names = xmlSearch(xml, "//name")>
|
||||
<!--- visualize the results --->
|
||||
<cfdump var="#variables#">
|
||||
Loading…
Add table
Add a link
Reference in a new issue