johnafitch
07-28-2007, 06:14 PM
I'd like to set the xpath of a datapointer to a node within an arbitrarily deep XML dataset by using its attribute, decid. Currently I do this by using its depth in the dataset (an attribute, dlevel) and using (dlevel - 1) "*/" strings to look for the node of the appropriate type (typex) at the correct depth:
if (dlevel == "3") {
var xp = "my_ds:/mystuff/*/*/typex[@id=\'" + decid + "\']";
}
if (dlevel == "4") {
var xp = "my_ds:/mystuff/*/*/*/typex[@id=\'" + decid + "\']";
}
If my XML data is very deep, say 10 levels, I'll need the rather awkward string:
if (dlevel == "10") {
var xp = "my_ds:/mystuff/*/*/*/*/*/*/*/*/*/typex[@id=\'" + decid + "\']";
}
This is obviously very verbose and perhaps computationally inefficient. Given the xpath constructs supported by OL, is there a simple recursive approach to doing this?
Thanks,
JohnAFitch
if (dlevel == "3") {
var xp = "my_ds:/mystuff/*/*/typex[@id=\'" + decid + "\']";
}
if (dlevel == "4") {
var xp = "my_ds:/mystuff/*/*/*/typex[@id=\'" + decid + "\']";
}
If my XML data is very deep, say 10 levels, I'll need the rather awkward string:
if (dlevel == "10") {
var xp = "my_ds:/mystuff/*/*/*/*/*/*/*/*/*/typex[@id=\'" + decid + "\']";
}
This is obviously very verbose and perhaps computationally inefficient. Given the xpath constructs supported by OL, is there a simple recursive approach to doing this?
Thanks,
JohnAFitch