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 6546723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:44:34+00:00 2026-05-25T11:44:34+00:00

I know we should use JSON when receiving remote autocomplete suggestions, but I’m forced

  • 0

I know we should use JSON when receiving remote “autocomplete suggestions”, but I’m forced to use standard DOM valid XHTML

I have registered component of interface nsIAutoCompleteSearch and using this code, to get remote XHTML via XmlHttpRequest

var request = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
        .createInstance(Components.interfaces.nsIXMLHttpRequest);

so far OK. then I receive text from request.responseText and I need to parse DOM and get values, too overcomplicated with regexp

so here is a code with error:

Components.classes["@mozilla.org/feed-unescapehtml;1"]
                    .getService(Components.interfaces.nsIScriptableUnescapeHTML)
                    .parseFragment(request.responseText, false, null, document);

error saying document not defined. Because I’m in XPCOM component, I don’t have access to DOM of page or XUL overlays. This code is taken right from MDN Docs

I tried to create instance of nsIDOMDocument or nsIDOMHTMLDocument and loading them from @mozilla.org/dom/core;1 or @mozilla.org/dom/html;1, but these packages doesn’t seem to be accessible (error saying Components.classes['@mozilla.org/dom/core;1'] is undefined)

So Is there a way how to create new DOMDocument, insert request.responseText as HTML and then walk through its DOM structure?

function HTMLParser from given link is throwing same error about document not defined

Thanks

  • 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-25T11:44:34+00:00Added an answer on May 25, 2026 at 11:44 am

    If the server response is well-formed XHTML, you can just use the responseXML member of the request object.

    This only works if the server is returning content type text/xml, however. Otherwise you can force the MIME type to text/xml using XMLHttpRequest.overrideMimeType.

    A final possibility is to parse the document manually as in the original question. I would use DOMParser though. You can use it from an XPCOM component like this:

    var parser = Cc["@mozilla.org/xmlextras/domparser;1"].
      createInstance(Ci.nsIDOMParser);  
    var doc = parser.parseFromString(aStr, "text/xml");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know you should use a StringBuilder when concatenating strings but I was just
For my .NET/C# project, I need to use a JSON library but I should
I don't know what library I should include to be able to use @PartType(application/json)
I know you should use POST whenever data will be modified on a public
I dont know if I should use the httpcontext caching or the Enterprise Library
I would like to know what I should use to compile in C. I
I don't know which title I should use for this question. I have a
Accuracy Vs. Precision What I would like to know is whether I should use
I don't know how to use Quartz.dll in ASP.NET. Where should we write the
I know this should be simple and I should know it but it's eluding

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.