473,386 Members | 1,654 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,386 software developers and data experts.

Read entire xml file

Hi,
Can someone tell me how to get the content of entire xml file in
Firefox?
I am using this code to load the xml file.
if (document.implementation && document.implementation.createDocument)
{
xmlDoc = document.implementation.createDocument("","",null) ;
xmlDoc.async="false";
var isLoaded = xmlDoc.load("allcounties_3.xml");
if (isLoaded == true) {
//alert(xmlDoc.documentElement.xml);
}
}

I tried xmlDoc.documentElement.xml but it dont work.
How can I read the entire xml file in a variable?
Oct 6 '08 #1
1 2225
Sunny wrote:
I am using this code to load the xml file.
if (document.implementation && document.implementation.createDocument)
{
xmlDoc = document.implementation.createDocument("","",null) ;
xmlDoc.async="false";
You should assign a boolean value not a string to the async property:
xmlDoc.async = false;
However that blocks the browser while loading the document so that is
usually not a good idea. Consider to use asynchronous loading (async =
true) in a browser environment.
var isLoaded = xmlDoc.load("allcounties_3.xml");
if (isLoaded == true) {
//alert(xmlDoc.documentElement.xml);
}
}

I tried xmlDoc.documentElement.xml but it dont work.
How can I read the entire xml file in a variable?
Well xmlDoc is a variable containing the XML document as a DOM tree.
If you only want a string then I am not sure why you use
createDocument() and the load method, you could use XMLHttpRequest and
simply access responseText.
Or, if you think you need createDocument() and the load method, then you
need to serialize the DOM tree e.g.
var xml = new XMLSerializer().serializeToString(xmlDoc);

--

Martin Honnen
http://JavaScript.FAQTs.com/
Oct 6 '08 #2

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

Similar topics

10
by: ZafT | last post by:
Thanks in advance for any tips that might get me going in the right direction. I am working on a simple exercise for school that is supposed to use read to read a file (about 10 MB). I am...
5
by: Julia | last post by:
Strategy to read part of XML log file Hi, My log file will contains entries formatted as XML(i use this format since some time i would like to log entire objects) I am going to use ...
2
by: Emmanuel | last post by:
Hi there, My client would like to process an xml file. the structure of which is as below. <xml> <stockitem> <releaseddate>.....date value...</releaseddate> <...aditional tags for additional...
35
by: RyanS09 | last post by:
Hello- I am trying to write a snippet which will open a text file with an integer on each line. I would like to read the last integer in the file. I am currently using: file = fopen("f.txt",...
1
by: Stephen | last post by:
Hi All, is it possible to read a file and write to the same file but the condition is: 1. suppose there is a line "Today is Wednesday. A beautiful day" and I want to change it to "Today is...
0
by: TRB_NV | last post by:
I'm on a new hosted server platform which doesn't support PERL, so I'm converting some of my old code so it'll run as ASP. I have a routine I wrote in 1998 where I have a standard template Word...
24
by: rudranee | last post by:
hi there, can anyone tell me how to lines from a file which are odd numbered i.e. 1st,3rd,5th...lines. i tried incrementing file pointer by 2 (fp=fp+2) but it does'nt work Can someone give me...
23
by: ShaneO | last post by:
Hello, I wish to extract embedded string data from a file using a Binary Read method. The following code sample is used in VB.NET and similar code is used in VB6 - (Assume variable...
6
by: arnuld | last post by:
This works fine, I welcome any views/advices/coding-practices :) /* C++ Primer - 4/e * * Exercise 8.9 * STATEMENT: * write a program to store each line from a file into a *...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.