Cezary
unread,Apr 27, 2009, 12:55:37 PM4/27/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to DOMAssistant
Hello.
I have a small code, that using XPath, but I want to make code work
without XPath. The code is:
function makeQlist(paths, contextNode)
{
var ul = null;
var result = document.evaluate(paths.join(' | '), contextNode, null,
XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
var node;
while ((node = result.iterateNext()) != null){
if (ul === null)
{
ul = document.createElement('ul');
}
var li = document.createElement('li');
switch (node.tagName.toLowerCase())
{
case 'fieldset':
li.textContent = node.getElementsByTagName('legend')
[0].textContent;
break;
case 'table':
li.textContent = node.caption.textContent;
break;
default:
li.textContent = node.textContent;
}
ul.appendChild(li);
var nestedList = makeQlist(paths, node);
if (nestedList !== null)
{
li.appendChild(nestedList);
}
}
return ul;
}
window.onload = function()
{
document.body.appendChild(makeQlist(['h2', 'form/fieldset[legend]',
'fieldset[legend]', 'table[caption]'], document.body));
};
I need help with the transition from the XPath to DOM. Can someone
point me to rewrite the code using Domassistant? (cssByDOM?)
--
CT