Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

stream problems when using nsIDOMParser

82 views
Skip to first unread message

Dorian D.

unread,
Aug 4, 2004, 1:48:53 PM8/4/04
to
My purpose :
I wish to store document (or node) data in a file,
then retrieving those data anytime i want,
and update this document (or node).

My problem :
Once data are properly saved (included in <html> </html> tag for
indicating the content type), I cannot retrieve my data by helping
with the parseFromStream method from nsIDOMParser object. Error comes
up :

<< JavaScript error:
line 0: uncaught exception: [Exception... "Component returned failure
code:
0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIDOMParser.parseFromStream]"
nsresult:
"0x80070057 (NS_ERROR_ILLEGAL_VALUE)" >>

When i change charset value to "UTF-8" (instead of default "null"
value), error changes :

<< JavaScript error:
line 0: uncaught exception: [Exception... "Component returned failure
code:
0x80004001 (NS_ERROR_NOT_IMPLEMENTED) [nsIDOMParser.parseFromStream]"
nsresult: "0x80004001 (NS_ERROR_NOT_IMPLEMENTED)" >>


How can i fix this problem and make it possible to retrieving my
stored data…
You can directly write me a mail to doria...@free.fr

Excerpts of listing :

/*************************************/
Load = function()
/*************************************/
[…]
// open flag : readonly, permissions : read permission for local user
inputStream.init(currentFile,0x01,0400,0);

// purchase "text/html" stream content
var storedDocument =
streamParser.parseFromStream(inputStream,null,inputStream.available(),"text/html");
// error at this line !!!
[…]

/*************************************/
Store = function()
/*************************************/
[…]
mySerializer = new Serializer();
stringToSave = mySerializer.serializeToString(document);

// open an ouput stream
outputStream = new FileOutputStream();

// WriteOnly | Truncate, rwx permissions for local user
outputStream.init(currentFile,0x02 | 0x20,700,0);

// store content in currentFile
// mySerializer.serializeToStream(document, outputStream, "UTF-8");
outputStream.write(stringToSave,stringToSave.length);
[…]

/*************************************/
Stored data :
/*************************************/

<HTML>
<head> </head>
<body>
<div id = "contentarea" > blabla </div>
</body>


</HTML>

Boris Zbarsky

unread,
Aug 4, 2004, 1:55:41 PM8/4/04
to
Dorian D. wrote:
> streamParser.parseFromStream(inputStream,null,inputStream.available(),"text/html");

DOMParser only does XML. So the "text/html" is what's getting you the
NOT_IMPLEMENTED exception.

-Boris

Erik Arvidsson

unread,
Aug 4, 2004, 4:35:28 PM8/4/04
to Boris Zbarsky
Boris Zbarsky wrote:
> DOMParser only does XML. So the "text/html" is what's getting you the
> NOT_IMPLEMENTED exception.

Is there some other component that can be used from a chrome app to
parse HTML into a DOM tree?

erik

ps. If anyone else is interested the bug is:
http://bugzilla.mozilla.org/show_bug.cgi?id=102699

Boris Zbarsky

unread,
Aug 4, 2004, 4:43:41 PM8/4/04
to
Erik Arvidsson wrote:
> Is there some other component that can be used from a chrome app to
> parse HTML into a DOM tree?

At the moment, no. The HTML parsing code makes all sorts of assumptions about
availability of things like window objects associated with the document being
parsed...

That's being worked on, last I checked (search on "html content sink" and
"docshell" in bug summaries?)

-Boris

Dorian D.

unread,
Aug 5, 2004, 4:41:36 AM8/5/04
to
If DOMParser only parse XML, why in that case documents about it indicate :
"contentType: The content type of the string - either text/xml or text/html"
(www.xulplanet.com)
???

Erik Arvidsson <http://webfx.eae.net/contact.html#erik> wrote in message news:<cerhag$in...@ripley.netscape.com>...

Daniel Kirsch

unread,
Aug 5, 2004, 4:52:41 AM8/5/04
to
Dorian D. wrote:

> If DOMParser only parse XML, why in that case documents about it indicate :
> "contentType: The content type of the string - either text/xml or text/html"
> (www.xulplanet.com)
> ???

See the comments at the bottom of the page:
http://xulplanet.com/references/objref/DOMParser.html

I havn't checked out creating a document fragment using the suggested
range's createContextualFragment function, but this would be interesting
if it would work.

Daniel

Dorian D.

unread,
Aug 5, 2004, 3:06:09 PM8/5/04
to
I finally followed your advises and I used createContextualFragment...
Thanks you very much, it works perfectly... in this manner, i didnt
even use
nsIDOMParser.parseFromStream which is a real mess. Finally, i can load
and store div content quasi instantly by putting or taking off
fragments from my document : really nice !

Dorian.


Daniel Kirsch <Iwillnotr...@gmx.de> wrote in message news:<cessft$jpj$06$3...@news.t-online.com>...

0 new messages