If you're using Flash 8, XPath was already integrated into its library/API.


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Chris W.
Paterson
Sent: Tuesday, July 24, 2007 1:44 PM
To: [email protected]
Subject: Re: [Flashcoders] CDATA Html Text not working

Great!  That works!  Thanks so much!!

I'll look into that XPath... Maybe not for this project since it's on a
tight deadline, but for
the future!

Thanks!
Chris

--- Alan MacDougall <[EMAIL PROTECTED]> wrote:

> Chris W. Paterson wrote:
> > this.firstChild.childNodes[i].firstChild.childNodes[j].childNodes;---
this is how I am trying
> to
> > access the content of that node.
> >
> > First off, I'm guessing I should use .nodeValue?  Will that give me the
entire node with
> > "<![CDATA[]]>"?  Is it even possible to read the html value for html
text?
> >   
> 
> Yep, there's the problem. The content of an XML node is a node in itself 
> -- it's just a text node. It looks like this:
> 
> <foo>my text</foo>
> 
> <foo> --> part of node A
> my text --> node B
> </foo> --> part of node A
> 
> 
> So to get the text inside that <foo> tag, let's say we have:
> 
> var fooNode:XMLNode;
> var textNode:XMLNode = fooNode.firstChild;
> var myText:String = textNode.nodeValue;
> myTextField.htmlText = myText; // now it should look right
> 
> As you can see, the child node of <foo> is an XMLNode which contains the 
> text -- it's not the string itself. I've used CDATA in XML plenty of 
> times, and your HTML text fields will interpret the HTML as long as 
> you're getting the string value of the text node.
> 
> As for all that confusing child.firstChild.childNodes[n].child business, 
> may I suggest XFactorStudios' excellent XPath implementation? 
> www.xfactorstudio.com -- and then you can specify your XML with simple 
> syntax like this:
> 
> // gets an Array of XMLNodes; specifically, all <bar> inside a <foo>, 
> starting from rootNode
> var nodes:Array = XPath.selectNodes(rootNode, "foo/bar");
> 
> It's a less confusing than manually walking the XML tree, and allows 
> some pretty complex searches once you really get into it. ( 
> http://www.w3.org/TR/xpath is very dense, but section 2 may give you an 
> example of XPath's power.)
> 
> _______________________________________________
> [email protected]
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> 
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
> 



 



       
____________________________________________________________________________
________
Got a little couch potato? 
Check out fun summer activities for kids.
http://search.yahoo.com/search?fr=oni_on_mail&p=summer+activities+for+kids&c
s=bz 
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to