[thelist] Read local file in gecko
Andrew Clover
and-evolt at doxdesk.com
Wed Dec 15 05:38:45 CST 2004
<u233 at shaw.ca> wrote:
> I'm working on a project to build a gecko-based application that needs to open
> an XML file from the user's hard drive and read it's DOM tree. The
> application resides on the user's hard drive too
> I've tried XMLHttpRequest
As the name implies, this only works with HTTP. (As the name doesn't
imply, though, it doesn't only work with XML!)
> document.implementation.createDocument
Should work. Mozilla doesn't support DOM Level 3 LS, but you can use
document.open. This works for me:
var d= document.implementation.createDocument(null, 'x', null)
d.load('file:///C:/something.xml');
> and <object />.
Should work. The trick is that you still have to use the window.frames
array to access the document, as if it were an <iframe>; there's no
property to get to the document from the HTMLObjectElement:
<object data="file:///C:/something.xml"></object>
var d= window.frames[0].document;
(Or you can just use an iframe in the same way.) Anyway note that the
document won't be readable until you've given it time to load.
--
Andrew Clover
mailto:and at doxdesk.com
http://www.doxdesk.com/
More information about the thelist
mailing list