views:

65

answers:

1

I'm developing a Firefox add-on and want to get the document content (DOM Elements) of an URL for parsing some data but don't want user to see this action. Is there any way to open an URL in a hidden tab and get the document content of this tab? Or any other solution?

A: 

Hi,

you could use Javascript to do that. Have a closer look at the xmlhttpRequest function. http://en.wikipedia.org/wiki/XMLHttpRequest

Carsten C.
Ajax only return text result and I can't find any HTML parser to parse the response string and traverse it like a DOM tree
hvtuananh
Hm? Maybe i did't get your Question - XHR is a DOM API, you will get a Dom-document-object, you can simply add it to your current Dom. (https://developer.mozilla.org/en/XMLHttpRequest)
Carsten C.
I mean the result of XHR is text, right? For example, if i call XHR function for http://www.google.com, will I get result in text format or DOM object format?
hvtuananh
You can get the result as String or XML, both can be passed to a parser (eg. parser=new DOMParser(); xmlDoc=parser.parseFromString(text,"text/xml");)
Carsten C.