PDA

View Full Version : xpathQuery() vs getXPath()


ch_bowen
04-08-2004, 11:55 AM
I have a question regarding the use of LzDatapointer.xpathQuery() vs LzDataPointer.getXPath(). It seems when using the xpathQuery() method, then calling setNodeAttribute(), in the debug window I get the following message:

"call to undefined method 'setNodeAttribute'"

However, when using dp.getXPath() then set the node attribute, it works fine. How do I modify a node attribute if I want to avoid using dp.getXPath().

//doesn't work!
var test1 = dp.xpathQuery('parent/child[1]');
test1.setNodeAttribute('value', 'aValue');

//works fine!
var test2 = dp.getXPath('parent');
var child = test2.getXPath('child[1]');
child.setNodeAttribute('value', 'aValue');

Thank you,
Chris

adam
04-09-2004, 07:12 AM
the docs for xpathQuery incorrectly say that the return type of xpathQuery is a datapointer or an array of datapointers. This is true of getXPath, but xpathQuery returns an LzDataNode in this situation.

You can look at the reference on this class (it's like a JDOM node) but you can use test1.setAttr( attrname, attval ) to set an attribute on it.

antun
04-09-2004, 08:35 AM
By the way, the docs for LzDataNode are here:

http://www.laszlosystems.com/lps-2.1/docs/lzx-reference/?lzdatanode.html

LzDataNode is new in 2.0.

-Antun

ch_bowen
04-12-2004, 12:57 PM
Thanks alot!!!