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

  • SEARCH
  • Home
  • 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 627751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:33:44+00:00 2026-05-13T19:33:44+00:00

I have made a firefox extension which loads a web page using xmlhttprequest .

  • 0

I have made a firefox extension which loads a web page using xmlhttprequest.

My extension has it’s own window opened alongside the main Firefox.

The idea of my extension is to load a webpage in memory, modify it and publish in newly opened tab in firefox.

The webpage has a div with id “Content”. And that’s the div i want to modify. I have been using XPath alot in greaseMonkey scripts and so i wanted to use it in my extension, however, i have a problem. It seems it doesn’t work as i would want. I always get the result of 0.

var pageContents = result.responseText; //webpage which was loaded via xmlhttprequest
var localDiv = document.createElement("div"); //div to keep webpage data
localDiv.innerHTML = pageContents;
// trying to evaluate and get the div i need
var rList = document.evaluate('//div[@id="content"]', localDiv, null XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);

The result is always 0 as i said. Now i have created the local div to store website data because i cannot parse the text using XPath. And document in this case is my extensions XUL document/window.

I did expect it to work, but i was wrong.

I know how to extract the div using string.indexOf(str) and then slice(..). However, thats very slow and is not handy, because i need to modify the contents. Change the background, borders of the many forms inside this div. And for this job, i have not seen a better method than evaluating XPath to get all the nodes i need.

So main question is, how to use XPath to parse loaded web page in firefox extension?

Thank you

  • 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-13T19:33:44+00:00Added an answer on May 13, 2026 at 7:33 pm

    Why not load the page in a tab, then modify it in place, like Greasemonkey does?

    As for your code, you don’t say where it executes (i.e. what is document.location?), but assuming it runs in a XUL window, it makes no sense — document.createElement will not create an HTML element (but a XUL div element, which has no special meaning), innerHTML shouldn’t work for such element, etc.

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

Sidebar

Related Questions

I have a web page which has many divs (listed like table rows), and
I have made my own exception class which derives from runtime_error and is getting
I have made an app which will be a FB page tab. Now I
I have made a http request using Firefox.Now the request header shows the following:
We have a web app + web site, which has performance issues. I have
I have made few changes on this huge JSF page, which is full of
I have made a cart and the cart has remove item button, but the
I have made a website using( Asp.net, c# ) and its content in English
I have made a String[] array by using String.split(.) . I am now trying
I have made an iphone application like flip cards in which values of cards

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.