Yes i agree it would be nice if it was a one liner :) since its kind of
defeating the purpose of why I like using xpath in the first place.
Merrill, Jason wrote:
OK Martin, you win, that works, thanks. :) But it IS a pain in the ass
to have to use three lines of code to get a single string from an XML
file, don't you think? It could be compacted into one or two lines, but
it would be even messier.
var nodes:Array = XPath.selectNodes(my_xml, "/pathto[1]/xml/text()");
var textnode:XMLNode = XMLNode(nodes[0]);
var text:String = textnode.nodeValue;
Thanks for the help. I hope AS 3 will address some of these issues.
But I think its going to be the same thing most likely.
Jason Merrill | E-Learning Solutions | icfconsulting.com
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:flashcoders-
[EMAIL PROTECTED] On Behalf Of Morten Barklund Shockwaved
Sent: Wednesday, December 07, 2005 4:02 PM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] Xpath and HTML tags inside XML bug?
Mike Boutin wrote:
even in this case the result is undefined
string = XPath.selectNodes(my_xml, "/pathto[1]/xml").nodeValue;
I've just gotten the libraries, and it is exactly as I expected.
selectNodes returns an Array of XMLNode-objects. Even the notion of
/text() is just to get the node, which has no name, as it is a
textnode
- but it does not mean, that it will return the text. The function
will
still return an array of XMLNode-objects. So in order to actually get
the text, you need to select the corrent index in the array, and then
get the nodeValue from the XMLNode. given:
var nodes:Array = XPath.selectNodes(my_xml, "/pathto[1]/xml/text()");
var textnode:XMLNode = XMLNode(nodes[0]);
var text:String = textnode.nodeValue;
That would be the proper way to do this perfectly and correctly. And
rather OOP and nice too :)
--
Morten Barklund - Information Architect - Shockwaved
Gothersgade 49, 4th floor - DK-1123 Copenhagen K, Denmark
Phone: +45 7027 2227 - Fax: +45 3369 1174
_______________________________________________
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