Why not use Xpath.selectSingleNode() if you are only looking for one node?

mySting = XPath.selectSingleNode(myXML,
"/content/biog").firstChild.nodeValue;

Works fine in my application in a node with CDATA content.

-Chris

On 2/3/06, Merrill, Jason <[EMAIL PROTECTED]> wrote:
>
> This is the only thing I have found that works:
>
> XMLNode((XPath.selectNodes(myXML,"root/node/text()")[0])).nodeValue;
>
> Ugly isn't it?
>
> Jason Merrill   |   E-Learning Solutions   |  icfconsulting.com
>
>
>
>
>
>
>
>
>
>
> >>-----Original Message-----
> >>From: [EMAIL PROTECTED] [mailto:flashcoders-
> >>[EMAIL PROTECTED] On Behalf Of Mark Burvill
> >>Sent: Friday, February 03, 2006 11:20 AM
> >>To: Flashcoders mailing list
> >>Subject: Re: [Flashcoders] Question about xpath and cdata
> >>
> >>Anyone?
> >>
> >>:o)
> >>
> >>Mark Burvill wrote:
> >>
> >>> Hi everyone,
> >>>
> >>> I'm still a bit new to using xml with flash, and I'm just starting
> to
> >>> dig into xfactorstudio's xpath for AS2.
> >>> I'm generally loving the way it's clearly going to save me loads of
> >>> time in searching through my xml docs, but I'm having a bit of a
> >>> probem getting html formatted text from a CDATA tag to display
> >>> properly....
> >>>
> >>> Say this is my xml file:
> >>>
> >>> <content>
> >>>    <biog>
> >>>        <![CDATA[Lorem ipsum dolor<br><br>sit amet.]]>
> >>>    </biog>
> >>> </content>
> >>>
> >>> What I'm trying to do is get the "Lorem ipsum" text and display it
> in
> >>> an html text field in Flash.
> >>>
> >>> I would normally do something like this:
> >>> var myText:String =
> myXML.firstChild.firstChild.firstChild.nodeValue;
> >>>
> >>> Using "nodeValue" makes sure that the text gets treated as html, and
> >>> the line breaks work properly rather than doing:
> >>> var myText:String =  myXML.firstChild.firstChild.firstChild;
> >>> ... which would display "Lorem ipsum dolor<br><br>sit amet." in my
> >>> textfield - not good.
> >>>
> >>> My question is, how do I get the same result using xpath?
> >>>
> >>> Doing this:
> >>> XPath.selectNodes (myXML, "/content/biog/text()");
> >>> ..gives me the right text, but won't treat it as html.
> >>>
> >>> Thanks!
> >>>
> >>> Mark.
> >>>
> >>
> >>--
> >>*Mark Burvill*
> >>Interactive designer
> >>www.eyegas.com <http://www.eyegas.com>
> >>
> >>*Work:* 0117 953 0100
> >>*Mobile*: 07780 608498
> >>
> >>_______________________________________________
> >>Flashcoders mailing list
> >>Flashcoders@chattyfig.figleaf.com
> >>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> NOTICE:
> This message is for the designated recipient only and may contain
> privileged or confidential information. If you have received it in error,
> please notify the sender immediately and delete the original. Any other use
> of this e-mail by you is prohibited.
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to