473,773 Members | 2,315 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Loading XML config file for web page

TMN
Hi All

If I want to use an xml file to hold some config parameters for a web
page do I need to load it with JS
or is there a way of including it in the <head?

Thanks
Tim
Jun 27 '08 #1
5 2597
TMN wrote:
If I want to use an xml file to hold some config parameters for a web
page do I need to load it with JS
Yes, use XMLHttpRequest for best cross-browser support to load the file.
or is there a way of including it in the <head?
Only IE has a concept of a so called XML data island where you can load
XML data inside of a HTML document using an 'xml' element e.g.
<xml id="x1" src="file.xml"> </xml>
But that is not supported by other browsers.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jun 27 '08 #2
TMN wrote:
Hi All

If I want to use an xml file to hold some config parameters for a web
page do I need to load it with JS
or is there a way of including it in the <head?
Use XMLHttpRequest to collect the data.
Jun 27 '08 #3
TMN
On May 14, 6:33 pm, The Magpie <use...@pigsins pace.co.ukwrote :
TMN wrote:
Hi All
If I want to use an xml file to hold some config parameters for a web
page do I need to load it with JS
or is there a way of including it in the <head?

Use XMLHttpRequest to collect the data.
Thanks - It just seems something like <xml id="x1" src="file.xml"</
xmlis so natural for a browser !!!

regards
Tim
Jun 27 '08 #4
joe
TMN <na******@gmail .comwrote:
>Hi All

If I want to use an xml file to hold some config parameters for a web
page do I need to load it with JS
or is there a way of including it in the <head?

Thanks
Tim

Here a sample how to load a page with Javascript.
Be adivsed that it returns immediately. So if you use it to intialize variables
do them in "whatever" function.

Here' what I mean (pseudocode):

line 0: ..
line 1: blah, blah;
line 2: loadXMLDoc(..); //loads a value to "myvar"
line 3: if (myvar==1)
line 4: blah, blah;
line 5: ...

When execution of code reaches Line 4 you'd expect "myvar" to have some value.
Not so! Caveat! "whatever" is executed (see below example code) when it's good
and ready. loadXMLDoc(..) returns immediately (well almost).



loadXMLDoc("htt p://www.yourhomepag e.com/somefile.txt");

function loadXMLDoc(url)
{
xmlhttp=null;
if (window.XMLHttp Request)
{// code for IE7, Firefox, Opera, etc.
xmlhttp=new XMLHttpRequest( );
}
else if (window.ActiveX Object)
{// code for IE6, IE5
xmlhttp=new ActiveXObject(" Microsoft.XMLHT TP");
}
if (xmlhttp!=null)
{
xmlhttp.onready statechange=wha tever;
xmlhttp.open("G ET",url,true) ;
xmlhttp.send(nu ll);
}
else
{
alert("Your browser does not support it.");
}
}

function whatever()
{
if (xmlhttp.readyS tate==4)
{// 4 = "loaded"
if (xmlhttp.status ==200)
{// 200 = "OK"
myvar=1; //remove this line, not necessary
alert("It worked, here's the contents:" + xmlhttp.respons eText);
}
else if (xmlhttp.status ==404)
{
alert("Dang! no workee:" + xmlhttp.respons eText);
}
else
{
alert("Som uther problemo:" + xmlhttp.respons eText);
}
}
}
Jun 27 '08 #5
On May 15, 7:53 am, joe <m...@invalid.c omwrote:
TMN <nash....@gmail .comwrote:
Hi All
If I want to use an xml file to hold some config parameters for a web
page do I need to load it with JS
or is there a way of including it in the <head?
Thanks
Tim

Here a sample how to load a page with Javascript.
Be adivsed that it returns immediately. So if you use it to intialize variables
do them in "whatever" function.

Here' what I mean (pseudocode):

line 0: ..
line 1: blah, blah;
line 2: loadXMLDoc(..); //loads a value to "myvar"
line 3: if (myvar==1)
line 4: blah, blah;
line 5: ...

When execution of code reaches Line 4 you'd expect "myvar" to have some value.
Not so! Caveat! "whatever" is executed (see below example code) when it's good
and ready. loadXMLDoc(..) returns immediately (well almost).

loadXMLDoc("htt p://www.yourhomepag e.com/somefile.txt");

function loadXMLDoc(url)
{
xmlhttp=null;
if (window.XMLHttp Request)
{// code for IE7, Firefox, Opera, etc.
xmlhttp=new XMLHttpRequest( );
}
else if (window.ActiveX Object)
{// code for IE6, IE5
xmlhttp=new ActiveXObject(" Microsoft.XMLHT TP");
}
if (xmlhttp!=null)
{
xmlhttp.onready statechange=wha tever;
xmlhttp.open("G ET",url,true) ;
xmlhttp.send(nu ll);
}
else
{
alert("Your browser does not support it.");
}

}

function whatever()
{
if (xmlhttp.readyS tate==4)
{// 4 = "loaded"
if (xmlhttp.status ==200)
{// 200 = "OK"
myvar=1; //remove this line, not necessary
alert("It worked, here's the contents:" + xmlhttp.respons eText);
}
else if (xmlhttp.status ==404)
{
alert("Dang! no workee:" + xmlhttp.respons eText);
}
else
{
alert("Som uther problemo:" + xmlhttp.respons eText);
}
}

}
Thanks to all who responded.

Tim
South Africa
Jun 27 '08 #6

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

Similar topics

1
2736
by: Joe | last post by:
Hi Does anyone know of any issues about loading config files for windows forms applications? I have an application that utilizes a config file that holds my database connection string as well as other user settings. With the original VS.NET, when loading the application through the IDE debugger everything went as planned and the config file was loaded. Now with VS.NET 2003 it seems that when I run the debugger the config file
1
4394
by: Chris | last post by:
I have seen the posts on various places on the internet about .NET framework mismatch issues and I don't think that is my problem. ; ) When I execute the following C++.NET code: String *ipAddress = S""; IDictionary *server_config = dynamic_cast<IDictionary*>(ConfigurationSettings::GetConfig("ServerAddress") ); ipAddress = dynamic_cast<String*>(server_config->get_Item(S"IP"));
0
1166
by: Jeff | last post by:
Hello, I've run into a problem with my asp.net application and would like to know whether the error is likely with my remote host. The problem is an unhandled exception, and the exception details are as follows: System.Configuration.ConfigurationException: Error loading XML file c:\winnt\microsoft.net\framework\v1.0.3705\Config\machine.config Request for the permission of type System.Security.Permissions.StrongNameIdentityPermission,...
2
1804
by: Jeff | last post by:
Hello, I've run into a problem with my asp.net application and would like to know whether the error is likely with my remote host. The problem is an unhandled exception, and the exception details are as follows: System.Configuration.ConfigurationException: Error loading XML file c:\winnt\microsoft.net\framework\v1.0.3705\Config\machine.config Request for the permission of type System.Security.Permissions.StrongNameIdentityPermission,...
13
1859
by: Duron | last post by:
I created a new folder using VS.NET 2003. Then I created a new web form under that folder, say, \Member\Default.aspx. However, even if I didn't do anything to that page, a run-time error appears when I try to run it -- Can not load class MySite._Default. I am using VB to write codes. Does anyone have any idea why this problem happens? Thanks!
2
1280
by: Patrick Olurotimi Ige | last post by:
Is it possible to execute a query or do some validation before loading a page.. I have a survey page and i want to validate users before loading the page. I have done it in the page_load. But the problem i have is that if the user gets the URL and directly paste it to the browser the USER still sees the page. Is there a way how to check the user in the DB before loading the page (I mean just by pasting the URL to the browser or just by...
7
10964
by: R Reyes | last post by:
Can someone please explain to me why I can't get the MS Word Interop assembly to work in my VS2005 project? I'm trying to manipulate MS Word from my Web Form application and I can't get passed this screen below. Please help, thanks in advance... Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify...
5
12929
by: greenflame | last post by:
hello all, I have installed apache and php following the instructions on this link which was very helpful: http://www.tanguay.at/installPhp5.php5 problem: OS: Windows XP
0
1714
by: AndySummers | last post by:
Hi We have just re-written a majour asp.net project to use a user control embedded in a web page. The main dll references 3 other custom controls and so to deploy the project I copy the 4 dll's to the server and the web page loads the control via the <object> tag. I have also added a iexplore.exe.config file (because of another thread) where I specify that .net v1.1 should be used. (The controls have been developed in VS2003) I have also...
3
12061
by: Mike | last post by:
Hi I have problem as folow: Caught Exception: System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. (machine.config) ---> System.Security.SecurityException: Request for the permission of type
0
9454
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
10264
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...
0
10106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8937
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7463
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5355
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
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4012
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.