I’m using a simple dom parser function to catch xpath information of all nodes of a document
say html is like :
[code=html]
<div>
<div>Everyday People</div>
<div>My name is ACE</div>
<div>Hello world</div>
</div>
and parsing the DOM to store the xpath infor in array ‘arr’
[CODE]
<script type=”text/javascript” src=”js/jquery/js/jquery-1.3.2.min.js”></script>
<script type=”text/javascript” src=”js/jquery/js/xpath-selector.js”></script>
<script type=”text/javascript”>
function get_XPath(elt)
{var path = ”;
for (; elt && elt.nodeType==1; elt=elt.parentNode)
{var idx=$(elt.parentNode).children(elt.tagName).index(elt)+1;
idx>1 ? (idx='[‘+idx+’]’) : (idx=”);
path=’/’+elt.tagName.toLowerCase()+idx+path;
}
return path;
}
var arr = Array();
htmlDoc=document;
x=htmlDoc.documentElement.childNodes;
for (i=0;i<x.length;i++)
{
arr.push(get_XPath(x[i]));
}
</script>
and later on in the script using the values stored in ‘arr’ to perform some functions like showing,hiding or changing content of nodes.
[CODE]
<script>
for(i=0;i<arr.length;i++)
{
//catch the object reference with the xpath info
$(arr[i])
}
</script>
But in the snippet above,I’m getting a object but unable to I’m unable to get the object reference..and use it for something like
$(arr[i]).text();
any help would be greatly welcome.
Anyone worked on Jquery Xpath selectors?