Hi Daniel, you are right: I somehow messed up the xpath argument when posting. I tried the code I had posted in the playground and it yielded "null", as you exptected. I have now modified the code according to your suggestions - it works! The code now looks like this:
var tables = qx.xml.Element.selectNodes(xml, "//table"); var singleNode = qx.xml.Element.selectSingleNode(tables[1],"name"); alert(qx.xml.Element.getSingleNodeText(singleNode,"text()")); Thank you very much! Michael Daniel Wagner schrieb: > Hi Michael, > > I just tried to reproduce the problem in the Playground but got null > instead of the first node's text. That's actually correct, because in > your call to getSingleNodeText you're asking for the text of another > node called "name" which is a child of the root element for the search > (the actual "name" node). If you want to access the text value of the > root node for the search, you have to use the query "text()". > > I have no idea why you're getting the wrong node's text. Which version > of qooxdoo are you working with? Do you get the same result when running > your code in the Playground? > > > Regards, > Daniel > > Michael Helwig schrieb: >> Hello, >> I'm having problems with xml processing. Since I haven't worked much >> with XML, it's probably a very basic mistake, but I don't see what's >> wrong. So here is the XML: >> >> <?xml version="1.0" encoding="UTF-8"?> >> <config> >> <database name="db"> >> <table> >> <name>firstTable</name> >> </table> >> <table> >> <name>secondTable</name> >> </table> >> </database> >> </config> >> >> and the following code is supposed to select the name-entry of the >> second node (which it doesn't) - the varible "xml" contains the >> document (it yields the correct output when serialized): >> >> var tables = qx.xml.Element.selectNodes(xml, "//table"); >> var singleNode = qx.xml.Element.selectSingleNode(tables[1],"name"); >> alert(qx.xml.Element.getSingleNodeText(singleNode,"name")); >> >> The alert gives "firstTable". However, tables[1] yields the expected >> output when serialized, i.e. it contains the second table section. >> Nonetheless, I get the text of the first "name" node when trying to >> access the second one. So what am I doing wrong? >> >> Thanks in advance and sorry for this basic question. >> >> Michael >> >> >> ------------------------------------------------------------------------------ >> Crystal Reports - New Free Runtime and 30 Day Trial >> Check out the new simplified licensing option that enables >> unlimited royalty-free distribution of the report engine >> for externally facing server and web deployment. >> http://p.sf.net/sfu/businessobjects >> _______________________________________________ >> qooxdoo-devel mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel >> >> > > > ------------------------------------------------------------------------------ > Crystal Reports - New Free Runtime and 30 Day Trial > Check out the new simplified licensing option that enables > unlimited royalty-free distribution of the report engine > for externally facing server and web deployment. > http://p.sf.net/sfu/businessobjects ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ qooxdoo-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
