473,809 Members | 2,740 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.imple mentation && document.implem entation.create Document)
{
xmlDoc = document.implem entation.create Document("","", null);
xmlDoc.async="f alse";
var isLoaded = xmlDoc.load("al lcounties_3.xml ");
if (isLoaded == true) {
//alert(xmlDoc.do cumentElement.x ml);
}
}

I tried xmlDoc.document Element.xml but it dont work.
How can I read the entire xml file in a variable?
Oct 6 '08 #1
1 2245
Sunny wrote:
I am using this code to load the xml file.
if (document.imple mentation && document.implem entation.create Document)
{
xmlDoc = document.implem entation.create Document("","", null);
xmlDoc.async="f alse";
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("al lcounties_3.xml ");
if (isLoaded == true) {
//alert(xmlDoc.do cumentElement.x ml);
}
}

I tried xmlDoc.document Element.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() .serializeToStr ing(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
2291
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 supposed to change the buffer size and see how this affects the read time. In other words, the buffer is supposed to limit how much of the file gets read per call, and cause some change in speed. I am supposed to do the same with fread as well, but...
5
2884
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 FileSystemWatcher in order to detect when changes occur to the file and now I am facing a problem reading the last added node I came to the following strategy:
2
1413
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 info> </stockitem> <stockitem>
35
11532
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", "r+"); fseek(file, -2, SEEK_END); fscanf(file, "%d", &c); this works fine if the integer is only a single character. When I get into larger numbers though (e.g. 502) it only reads in the 2. Is there
1
1333
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 Thursday. A beautiful day" Thanks, Stephen
0
2262
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 file that I do some replacing in and then fax it out to the end user. I'm trying to read the entire file in as a string variable, but since the file isn't text it's not getting the whole thing and I can't find a simple easy way to do it yet, so...
24
6162
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 the code please.
23
2841
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 declarations etc.) FileOpen(iFileIn, sInputFile, OpenMode.Binary, OpenAccess.Read)
6
5721
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 * vector<string>. Now, use istringstream to read read each line * from the vector a word at a time.
0
9601
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10637
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10379
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10115
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3014
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.