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