Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

XPath...


SySTeM's Avatar
-=[TheOutlaw]=-
20 0

Well this isn't exactly "programming", more scripting, for those of you who are unsure what XPath is, it's used in JavaScript to get elements from XML files, which can then be used in a document, for example, you could get an XML file which contains books or something, and then display them in a page using XPath. This used to be pretty simple, but since Firefox 3 has come out, it's been made alot harder due to security measures being tightened. The node you have, needs to have the same "ownerDocument" as the node you got it from, which is impossible, as it will be from different documents… So, a function was introduced, "importNode()", this allows you, or is meant to allow you, to import nodes from external documents, and then clone them into the current document, however, this doesn't work well with XPath.

I am looking for anyone who has ever used XPath or has any knowledge about it to give me a hand fix my script that used to work for Firefox 2 and below, and also works for IE7 and below, to meet the Firefox 3 rules, as it is starting to give me a headache now.

My script is located here, I'd use a code box, but it messes up the formatting.

The error being thrown is: markupError: uncaught exception: [Exception... "Node cannot be used in a document other than the one in which it was created" code: "4" nsresult: "0x80530004 (NS_ERROR_DOM_WRONG_DOCUMENT_ERR)" location: "http://www.elites0ft.com/elites0ft-xml.js Line: 40"]

Thank you to any of you who reply and are of any help, it is very much appreciated :) ~system.

[Edit]Nevermind, I fixed it :)[/edit]


ghost's Avatar
0 0

what was the solution?


SySTeM's Avatar
-=[TheOutlaw]=-
20 0

The simplest, most stupidest solution possible.

I had to change: var aff = document.evaluate( affPath, xml, null, XPathResult.ANY_TYPE, null );

To: var aff = xml.evaluate( affPath, xml, null, XPathResult.ANY_TYPE, null );

Because xml is the owner >_<


SySTeM's Avatar
-=[TheOutlaw]=-
20 0

Yup, cheers for that Spy :)