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> </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>