473,320 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Open a XML and parse it with DOM

Hi,
how can I open an xml document and parse it with DOM? For example I want to
access it via getElementById and all this. I'm using Mozilla Firefox if
that's important (it's an application using XUL and SVG).

Thanks
Nov 23 '06 #1
1 1341
Carles Company Soler wrote:
how can I open an xml document and parse it with DOM? For example I want to
access it via getElementById and all this. I'm using Mozilla Firefox if
that's important (it's an application using XUL and SVG).
With Mozilla you have two options, you can create a dummy DOM XML
document e.g.

var xmlDocument = document.implementation.createDocument('', 'dummy',
null);
xmlDocument.onload = function (evt) {
// now access document contents here e.g.
alert('Found ' + xmlDocument.getElementsByTagName('*').length +
'eleemnts.');
};
xmlDocument.load('file.xml');

or you can use XMLHttpRequest to load the file and then access the
responseXML property.

Note that getElementById in XML documents does only work if the DTD
defines the attributes of type ID and the parser reads the DTD or has
that information hardcoded for certain elements (e.g. XHTML or SVG
elements).
--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 23 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Andy Fish | last post by:
Hi, I am trying to parse a file using Xerces' DOMParser.parse(String systemId) I have come across a problem where it refuses to open a file with curly braces "{" or "}" in the file name. I...
5
by: mike | last post by:
Is there any way I can change the content type when I open a new window other than opening a script in the open statement? mywin =...
115
by: TheAd | last post by:
At this moment I use MsAccess and i can build about every databound application i want. Who knows about a serious open source alternative? Because Windows will be a client platform for some time, i...
22
by: fniles | last post by:
I have a .CSV file (comma delimited) that I want to open using OLEDB, but I get the error "External table is not in the expected format." If I save the .CSV file to an .XLS file, I can open the...
4
by: Bob Bedford | last post by:
Hi all, I'm stuck with some php code that runs out of time limit. This is due to a long XML file process that has to save pictures on the disk. What I've now: - read XML file - parse XML...
3
by: nik | last post by:
Hi, I need to parse incoming SQL statements (SELECT, INSERT, DELETE etc) and generate a parse tree. Also i need to find out if there are syntax errors etc. Is there any open source SQL Parser...
10
by: Dave | last post by:
Access 2002...I need to open a popup at the location of a mouse dblclick. Can anyone help with this? I can get the mouse X & Y, but I'm not sure how to open a form in a specific location by code....
0
by: shaqa | last post by:
I try to do this but i cannot. i creat two layers with actionscript seperated as slideshow need to be,,and i try to put in one rectangle all of my images but cannot put in work,it doesnt load when i...
8
by: eastcoastguyz | last post by:
I'm very new to RSS. I was given a URL that starts with "feed:". I want to be able to open this and read in its content into a PHP program to produce a report. I'm not interested in converting it...
0
by: Mitchel Haas | last post by:
I've noticed several inquiries in the past for libraries/toolkits to generate or parse xhtml. Although there are already a few libraries available for this purpose, I'd like to announce a new...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.