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

XML dom to a file code....

Hi the changes that i am making using dom (see function modify) take place only in memory untill the next reload ..but not in my xml file

I am doing this for a customer and i am unable to install a
server side language to do a submit , how can i save the contents of
xmldoc directly to a file locally ?? I was thnking of active x , but can someone someone post some code? is that the best solution?



Contents of xml file :



<?xml version="1.0" encoding="UTF-8"?>
<Global_Emergency activated="off">
<VDN id="000" Country="GR" ServiceName="CA">
<Training_Emergency>off</Training_Emergency>
<Languages number="0" InitLanguage="EN">
<language/>
<language/>
<language/>
</Languages>
<Opening_Hours>
<General_Opening_Hours>
<day name="Monday" Open="08:00" Closed="17:00"/>
</General_Opening_Hours>
</Opening_Hours>
<Menus>
<Menu ID="MM" Name="Main Menu">
<option name="PARTS" type="Transfer" enabled="false"/>
</Menu>
<Menu ID="CLUBUS" Name="CLUB_US" submenuof="MM">
<option name="FORMS" type="Transfer" enabled="TRUE">22</
option>
</Menu>
</Menus>


HTML code:

<html>
<head>
<script type="text/javascript" src="js/loadxmldoc.js">
</script>



<form method="POST" onsubmit="return modify();">
<p>&nbsp;</p>


<script type="text/javascript">


function modify()


{


if (window.ActiveXObject)
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");


}


// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation.createDocument)
{
xmlDoc=document.implementation.createDocument(""," ",null);

}


else
{
alert('Your browser cannot handle this script');

}


xmlDoc.async=false;
xmlDoc.load("config.xml");

y=xmlDoc.getElementsByTagName('Global_Emergency');


alert ("we are in modify");
alert (xmlDoc);
//var x=xmlDoc.documentElement.getAttribute('activated') ;

//alert (x);

for(i=0;i<y.length;i++)
{
alert (i);
y.item(i).setAttribute("activated","newvalue");
}

for (i=0;i<y.length;i++)
{
document.write(y[i].getAttribute('activated'));
document.write("<br />");
}
//xmlDoc.documentElement.setAttribute('activated','n ewvalue');

}


function finalcheck()

{
alert ("hi");



}


function parseXML()
{
try
{//try IE first
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
catch(e)
{
try
{//try Mozilla, Firefox, Opera, etc.
xmlDoc=document.implementation.createDocument(""," ",null);
}
catch(e)
{
alert(e.message);
return;
}
}
xmlDoc.async=false;
xmlDoc.load("config.xml");

var y=xmlDoc.getElementsByTagName("VDN");


alert(y.length);


var x=xmlDoc.documentElement.childNodes;
alert(x.length);
var x=xmlDoc.documentElement.getAttribute('activated') ;


gedrop=document.getElementById("GE");


alert(x);


/*
for (var i=0; i< getdrop.options.length; i++)
{


alert (getdrop.options[i].text.toUpperCase() );
/*
if (getdrop.options[i].[gedrop.selectedIndex].value==x)
{
// alert ("found");
// alert (getdrop.options[i].[gedrop.selectedIndex]);
}
*/


if (x=="off")
{
alert ("that works"); //do nothing



}


else

{
gedrop.selectedIndex=1;



}


/*

if (gedrop.options[gedrop.selectedIndex].value==x)
{
alert ("index is"+gedrop.selectedIndex);


alert ("found");



}


else
{
if (gedrop.options[gedrop.selectedIndex]==0)
{gedrop.selectedIndex=1};


}


*/
//document.getElementById('GE').selectedIndex=
/*
=x;

document.getElementById('dropdownlistname').select edIndex =
indexNumber
alert (x);
*/


/*
document.getElementById("to").innerHTML=
xmlDoc.getElementsByTagName("to")[0].childNodes[0].nodeValue;
document.getElementById("from").innerHTML=
xmlDoc.getElementsByTagName("from")[0].childNodes[0].nodeValue;
document.getElementById("message").innerHTML=
xmlDoc.getElementsByTagName("body")[0].childNodes[0].nodeValue;


*/


}


</script>
</head>

<body onload="parseXML()">
<h1>Global Emergency <select size="1" id="GE" name="D1">
<option value="off">Not Active</option>
<option value="on">Active</option>
</select></h1>
<p><input type="submit" value="Submit" name="B1"><input
type="button" onclick="modify();" value="Button" name="B2"></p>
</form>
</body>
</html>
Mar 27 '08 #1
2 1927
This is solved..
I used active x to save the file and it works fine.
Mar 27 '08 #2
icesh
15
hello,, I have same problem as panos100m..
can anyone help me?
how can we save the file using active x?
thank you very much
Apr 6 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Brandon Walters | last post by:
I wrote a file download module for my website. The reason for the file download module is that my website downloads work on a credit based system. So I need to keep track of and limit daily...
3
by: Pernell Williams | last post by:
Hi all: I am new to Python, and this is my first post (and it won't be my last!), so HELLO EVERYONE!! I am attempting to use "xreadlines", an outer loop and an inner loop in conjunction with...
9
by: Hans-Joachim Widmaier | last post by:
Hi all. Handling files is an extremely frequent task in programming, so most programming languages have an abstraction of the basic files offered by the underlying operating system. This is...
7
by: A_StClaire_ | last post by:
hi, I'm working on a project spanning five .cpp files. each file was used to define a class. the first has my Main and an #include for each of the other files. problem is my third file...
1
by: ABCL | last post by:
Hi All, I am working on the situation where 2 different Process/Application(.net) tries to open file at the same time....Or one process is updating the file and another process tries to access...
1
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C programming. FYI Although I have called this...
6
Atran
by: Atran | last post by:
Hello: In this article: You will learn to Write or Read A Text File. Let's Begin: First Create a new project (ConsoleApp or WinApp). And Make sure your program uses these namespaces: using...
4
by: Vlad | last post by:
I am having problems using the file.create method within a function that is called when looping through an array of filepaths. If I call my function with a hardcoded file path --C:\Temp.txt the...
1
roswara
by: roswara | last post by:
Dear all, Currently, I am working on a project to make a web-based application using ASP 2.0 and C#. This application will ask user to input for an excel file which has graphs in it. Then the...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
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,...

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.