Hi Jerry
Your XPath expression was slightly too specific - it was only retrieving the
'rate' element from the document. The following code returns every child
element of 'record' and uses the [element]_[child element] convention to
name the query columns. This way you only have to run one query for all the
values!
<cfset myxml = "<Report>
<Record>
<state>ZZ</state>
<prod_type>M</prod_type>
<prod_no>1</prod_no>
<prod_name>30 yr fixed mtg</prod_name>
<rate>6.8</rate>
<apr_yld>7.04</apr_yld>
<rate_diff>D</rate_diff>
<b1wkrate>6.82</b1wkrate>
<b1wkapryld>7.06</b1wkapryld>
<b1morate>6.81</b1morate>
<b1moapryld>7.04</b1moapryld>
<b6morate>6.66</b6morate>
<b6moapryld>6.85</b6moapryld>
<thisday>7/11/01</thisday>
</Record></Report>">
<cf_xmlquery xmldata = "#myxml#"
name = "Rate30"
xpath = "//Record[prod_name='30 yr fixed mtg']"
debug = "yes">
<cfoutput query = "Rate30">
rate is #record_rate#<br />
state is #record_state#<br />
thisday is #record_thisday#<br />
and so on...
</cfoutput>
Watch out for the latest version of this tag, which - amongst other
improvements - will let you cache the XML 'datasource' for much improved
performance, and also allows SQL queries of XML documents.
Best wishes
Tom
-----------------+
tom dyson
t: +44 (0)1608 811870
m: +44 (0)7958 752657
[EMAIL PROTECTED]
http://torchbox.com
on 12/7/01 9:45 pm, Jerry Travioli at [EMAIL PROTECTED] wrote:
> I needs some assistance with my XPath expression. The XPath expression
> noted in the <cf_xmlquery> works fine - the probem is that I have to run a
> seperate query for each value (10 values x 11 prod_name). There must be a
> way around this - please provide input on how I need to change the XPath
> expression to obtain all value within this record.
>
> Thanks,
> Jerry Travioli
>
>
> <!--- output.cfm --->
>
> <cf_xmlquery
> xmldata = "avgs.xml"
> datatype = "file"
> name = "Rate30"
> xpath = "//Record[prod_name='30 yr fixed mtg']/rate"
> debug = "yes">
>
>
> <!--- avgs.xml --->
>
> <Report>
> :
> :
> <Record>
> <state>ZZ</state><prod_type>M</prod_type><prod_no>1</prod_no><prod_name>30
> yr fixed mtg
> </prod_name><rate>6.8</rate><apr_yld>7.04</apr_yld><rate_diff>D</rate_diff><
> b1wkrate>6.82</b1wkrate><b1wkapryld>7.06</b1wkapryld><b1morate>6.81</b1morat
> e><b1moapryld>7.04</b1moapryld><b6morate>6.66</b6morate><b6moapryld>6.85</b6
> moapryld><thisday>7/11/01</thisday>
> </Record>
> :
> :
> </Report>
-----------------------+
cf-xml mailing list
[EMAIL PROTECTED]
http://torchbox.com/xml