XPath conditional text node selection
- by Reinderien
Hi there. I need to construct an xpath string to select all descendants of a certain table with these conditions:
The table is a descendant of a form with a specific action attribute value.
The selected descendants are text nodes.
The text node content can only contain whitespace.
It'll probably look something like:
//form[@action = "submit.html"]//table//text()[ ...? ]
Any tips would be appreciated. Thanks.
Edit: For clarity, here is my current (working) compromise:
function KillTextNodes(rootpath)
{
XPathIterate(rootpath + '//text()', function(node)
{
var tagname = node.parentNode.tagName;
if (tagname != 'OPTION' && tagname != 'TH')
Kill(node);
});
}