<cfsavecontent variable="myXML">
<pages>
        <page id="myPage">
                <title>Blah</title>
        </page>
</pages>
</cfsavecontent>
<cfset myXML = XMLParse(myXML)>
<cfset xmlNode = XMLSearch(myXML,'/pages/[EMAIL PROTECTED]"myPage"]/title')>
<cfdump var="#xmlNode[1].xmlText#">

This works

If you had more than one <title> element, then the xmlNode var array would
increment

Steve

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Mark
Stanton
Sent: Wednesday, November 26, 2003 11:43 AM
To: CFAussie Mailing List
Subject: [cfaussie] Selecting a text node with text() and XMLSearch


Hey All

I've got a small issue XMLSearch, I've got an xml document:

<pages>
        <page id="myPage">
                <title>Blah</title>
        </page>
</pages>

which I'm reading in as #myXML#.

The following code:

<cfdump var="#XMLSearch(myXML,'/pages/[EMAIL PROTECTED]"myPage"]/title')#">

outputs an array containing the xml element for <title>, but what I really
want is just the text "Blah". Going through some XML docs I've read
(http://www.w3.org/TR/xpath#node-tests,
http://www.nwalsh.com/docs/tutorials/xsl/xsl/frames.html) it looks like
text() should return the content of the <title> node. So....

<cfdump var="#XMLSearch(myXML,'/pages/[EMAIL PROTECTED]"myPage"]/title/text()')#">

...but that returns an array containing the text "[unknown type]".

Any ideas?


Cheers

Mark


------------------
Mark Stanton
Technical Director
Gruden Pty Ltd
Tel: 9956 6388
Mob: 0410 458 201
Fax: 9956 8433
http://www.gruden.com


---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
http://www.mxdu.com/ + 24-25 February, 2004


---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
http://www.mxdu.com/ + 24-25 February, 2004

Reply via email to