I have an xml and xsl file and I can use xmlTransform() to successfully transform the data. However when I try to use xmlSearch() to filter the data it throws an error.
I keep getting the following error message:
Unsupported argument type in an XML function.
The XML function [XmlTransform] only allows arguments of type [String, XmlDocument].
Here is the xml structure:
<?xml version="1.0" encoding="UTF-8"?>
<guestbook>
<message date="2004-12-13" id="1">
<name>peter</name>
<email>peter@nowhere.com</
email>
<comment>asld jaskd</comment>
</message>
<message date="2004-12-19" id="2">
<name>sam</name>
<email>sam@somewhere.com</
email>
<comment>asld jasad as dskd</comment>
</message>
</guestbook>
Here is the xsl file:
<xsl:stylesheet version="1.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<table width="100%">
<xsl:for-each select="message">
<tr>
<td><strong><xsl:value-of select="name"/></strong> <xsl:value-of select="email"/></td>
</tr>
<tr>
<td>POSTED: <em><xsl:value-of select="date"/></em></td>
</tr>
<tr>
<td><xsl:value-of select="comment"/></td>
</tr>
<tr>
<td><hr color="#CFDAB5" size="1" /><br /></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
Here is my cfm code:
<!--- read XML and XSL files --->
<cffile action="READ" file="#request.libPath#\xm
l\guestboo
k.xml" variable="xmlFile">
<cffile action="READ" file="#request.libPath#\xm
l\guestboo
k.xsl" variable="xslFile">
<!--- create an xml object --->
<cfset parsedXML = xmlParse(xmlFile)>
<!--- just try and select the last record --->
<cfset parsedXML = xmlSearch(parsedXML, "/guestbook/message[last()
]")>
#xmlTransform(parsedXML, rawXsl)#
If I don't use xmlSearch the transform works. So I assume my xpath statement is wrong. And while im on the subject could anyone help me out with an xpath statement to select a range of nodes.
Start Free Trial