Simon - The CF XML Toolkit is a collection of tags I wrote with David
Maddison a couple of years ago; its purpose was to facilitate XML handling
for ColdFusion developers. Its 'killer feature' is the ability to deal with
an XML string as a standard datasource, even supporting SQL queries (via
CF's built-in SQL parser). The Toolkit is limited by its reliance on MSXML,
and became less relevant when CFMX - with its native XML functions - was
launched. For CFMX users who like the query interface to XML documents,
there's an updated version of the XML query tag (which doesn't rely on
MSXML) at http://www.torchbox.com/xml/cfmx_xmlquery.zip
Yuen - using SQL queries with the XMLQuery tag relies on your XML string
being formatted in a very simple, row-oriented way. If your source document
is complex, or nested to many levels, you'll need to use XPath:
<CF_XMLQuery Datasource="MyData" Name="test" Type="Xpath">
/RecordList/Record
</CF_XMLQuery>
<cfoutput query = "test">
company name: #record_company_name#<br />
company size: #record_company_size#<br />
</cfoutput>
As you can see, the resultset uses a naming convention for child elements
and attributes: [elementname]_[childelementname or attributename]
Although SQL access to XML documents is an interesting feature, I'd strongly
recommend learning Xpath, which is a simple query language designed to deal
with complex hierarchical data:
http://www.google.com/search?q=xpath tutorial
I hope this helps - let me know if you're still stuck
Best wishes
Tom
> Hi all,
> I recently dowloaded CFXML toolkit and encounter a problem using SQL
> or Xpath style to query XML file. The XML file format is something like
> this :
> <CF_XMLDatasource Name="MyData">
> <RecordList>
> <Record>
> <company_name>Dummy Company</company_name>
> <company_size>4</company_size>
> <alt_address>test</alt_address>
> </Record>
> <Record>
> <company_name>Dummy Company2</company_name>
> <alt_address>test</alt_address>
> </Record>
> <Record>
> <company_name>Dummy Company3</company_name>
> <company_size>5</company_size>
> </Record>
> </RecordList>
> </CF_XMLDatasource>
>
>
> When I run this code :
> <CF_XMLQuery Datasource="MyData" Name="test" Type="SQL">
> select company_name from MyData
> </CF_XMLQuery>
>
> Then I received this error message :
> Error Diagnostic Information
>
> An error occurred while evaluating the expression:
>
> valuetoput =
> replace(listgetat(attvaluelist,counter,'|'),'_nothing_','','one');
> QuerySetCell(xmlq,i,valuetoput);
> counter = counter + 1;
>
> Error near line 1, column 94.
> ------------------------------------------------------------------------------
> --
>
> The column name (Record_company_size) that you have specified is invalid.
> Either this query does not have a column
> with that name, or you have specified one of the reserved column names, e.g.,
> RecordCount
>
> The error occurred while processing an element with a general identifier of
> (CFSCRIPT),
> occupying document position (1:10415) to (1:10424) in the template file
> C:\CFusion\CustomTags\xml\XMLQuery.cfm.
>
> Please advice. Thanks in advance.
-----------------+
tom dyson
t: +44 (0)1608 811870
m: +44 (0)7958 752657
http://torchbox.com
-----------------------+
cf-xml mailing list
http://torchbox.com/xml/list.cfm