I have the following xpath that I need to run, but Jquery doesn't support the functions....so how can i actually make this work in jquery ?
$("//*[br]/text()[string-length(normalize-space()) != 0]").each( ....
I have the following xpath that I need to run, but Jquery doesn't support the functions....so how can i actually make this work in jquery ?
$("//*[br]/text()[string-length(normalize-space()) != 0]").each( ....
Um - modern jQuery doesn't support XPath. jQuery isn't an Xpath parsing utility.
However, I would recommend you actually translate that into jQuery... perhaps something like
$('*[br]').filter(function() {
var text = $(this).text(), normalized = $.trim( text );
return normalized.length>0
});
Though you may need an additional regex replacement of multiple whitespace, I'm not quite sure how that xsl/xpath function works.
Please check the new compatibility Plugin for JQuery:
http://docs.jquery.com/Release%3AjQuery%5F1.2#XPath%5FCompatibility%5FPlugin
But keep one thing in mind: "XPath is a language to traverse nodes in XML document during the transformation (look for XSLT)." :-)