Note that there are some explanatory texts on larger screens.

plurals
  1. POXPath/Javascript - INVALID_STATE_ERR when creating new nodes tree
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COConsider to post enough sample code allowing us to reproduce the problem, perhaps using a site like http://jsfiddle.net/. I am afraid a line like `var = iterator.iterateNext().cloneNode(true);` is not even syntactically correct. As for the XPath DOM API, consider to first iterate over the result to collect the nodes found, for instance in an array, then to manipulate the DOM tree. On the other hand a HTML document has exactly one `body` element, so why do you need to use an iterator? Shouldn't selecting a single node suffice?
      singulars
    2. COI tried to morph your snippets into a test case to reproduce the issue, here it is: http://jsfiddle.net/pe95g/2/. I think that example should work fine and it indeed does so in Mozilla and Opera, yet in Chrome and Safari I get an "INVALID_STATE_ERR: DOM Exception 11". In my understanding that is a bug in WebKit's DOM implementation although the DOM Level 3 XPath note is not particularly detailed as to what is a "document modification" that "invalidates the iteration". If I change the code to use a snapshot (http://jsfiddle.net/WT5Uk/1/) it works fine with Mozilla, Opera, Safari, Chrome.
      singulars
    3. COYou're right. I also tried this with snapshot but there I found another strange failure. When I use the evaluate function I use the definied function "evaluate( xpathExpression, contextNode, namespaceResolver, resultType, result );" in firefox but the same calling style leads to errors in chrome (15.0.874.106). There I have to call like that: "document.evaluate( xpath, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE)" Strange! But you're right the very same code from above runs in Firefox 7. (If you add your comment as answer I'll accept it because it helped me a lot)
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload