PDA

View Full Version : Xpath question : output+textfields show cat. name from xml



tristessa
March 1st, 2006, 07:44 AM
hello all,
**if it doesn't belong here, plz move**

fiddling around with Xpath sure is fun,
yet i come to a problem i can't seem to find the answer to.



var thePath_str:String = "/nutrition/food/name";
var titleNode:String = XPathAPI.selectSingleNode(this.firstChild, thePath_str);
knop.btntxt.text = titleNode.toString();
trace (titleNode.toString())

it works but the output give me this



<name>Avocado Dip</name>


how do i force it to show only Avocado Dip ?

the odd thing is : when i simple use the path to a text field fe.
"/nutrition/food/name/"


var nameselect = XPathAPI.selectSingleNode(this.firstChild, "/nutrition/food/name/");
knop.btntxt.text = nameselect;
trace (nameselect)

it outputs aswell <name>Avocado Dip</name>

but when i leave the "/" in the nameselect variable like this
so the path is "/nutrition/food/name"


var nameselect = XPathAPI.selectSingleNode(this.firstChild, "/nutrition/food/name");


i don't understand this so much

as anyone have a nice pointer?

thnx in advance.

tristessa
March 1st, 2006, 07:47 AM
sigh!!!!

damn, when i pressed place, i just thought of something.

i've altered the line to

"/nutrition/food/name/*"

and now it gives me the proper value with out the node tags

oh well, maybe this post is usefull for other members...

*cheers & dances on desk*