Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 968527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:29:44+00:00 2026-05-16T02:29:44+00:00

I was experimenting around with XPath, basically I’m trying to load a HTML page

  • 0

I was experimenting around with XPath, basically I’m trying to load a HTML page using XMLHttpRequest and select an element inside it from its XPath.

Here’s my code (Greasemonkey/Js):

GM_xmlhttpRequest({
method: 'GET',
url: url,
headers: {
    'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
    'Accept': 'application/atom+xml,application/xml,text/xml',
},
onload: function(responseDetails)
{
    var rs = document.evaluate("/html/body/div",responseDetails.responseText,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
    var n = rs.snapshotItem(0);
    alert(n.innerHTML);
}});

But it isn’t working.

This is the error I’m getting:

uncaught exception: [Exception... "Could not convert JavaScript argument arg 1
[nsIDOMXPathEvaluator.evaluate]" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" 
location: "JS frame :: file:///C:/Documents%20and%20Settings/Admin/Application%20Data
/Mozilla/Firefox/Profiles/mq3w8kw4.default/extensions/%7Be4a8a97b-f2ed-450b-
b12d-ee082ba24781%7D/components/greasemonkey.js :: anonymous :: line 587" data: no] 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T02:29:45+00:00Added an answer on May 16, 2026 at 2:29 am

    You are trying to run an XPath query on a string, responseText, try responseXML instead.

    Still, I’m guessing that unless the web page you are loading has completely valid XHTML, this too will fail. If you want to run XPath queries on mangled HTML, try loading loading it in an iframe, then use iframe.contentDocument.evaluate

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm experimenting with clojure and am trying to get a feel for using 3rd
I'm experimenting ideas around using AppDomain to manage some legacy code contains lots of
just messing around, trying to expand my bag o' tricks: I was just experimenting
I was goofing around and trying some regular expressions for the sake of experimenting
Experimenting with Scala... I'm trying to define something analogous to the @ hack in
Experimenting with android game development. I'm using PNG format for images, and was wondering
I'm experimenting with MVVM and I can't quite wrap my mind around it. I
I've been experimenting with OpenID, and have set up a sample web page to
I'm rather new to SOA and therefore experimenting around. Currently, the part that creates
I'm experimenting with MongoDB using the PHP PECL extension, however I'm having difficulty getting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.