Hi ,

I am developing a web page . For this i am using Javascript embedded in html. In the application ,the user can input data via interfaces in the page which is chosen and read from a master xml file , the chosen data then needs to be stored and saved in a xml file . I have designed the web page in FrontPage.

Now the problem i face is while trying to save the output xml file i get error Permission Denied , error code 0 . This happens when i try to open the page in browser IE 6.0 SP2

I am using DOM parser methods for doing the xml manipulations/savings etc.

Surprisingly this works in another machine.
Could i get some pointers ..as to wat i should do to get rid of the Permission denied problem.

Also can i use the all of the same javascript code if i want to run it in an IIS. Do i have to do some changes to make it server side javascript code.

Kindly do give your suggestions.

Regards
Sangram

Bakshi,

In your forst paragraph you say, "the chosen data then needs to be stored and saved in a xml file".

Where exactly do you intend this file to be saved and can you post the code that is supposed to perform the save?

Airshow

Hi ,

Thanks for your reply . I am trying to read data from a master xml file in d drive and i save the chosen data in c : drive.

The code i use is :

savexml(){
var TristateFalse = 0;
var ForWriting = 2;
myActiveXObject = new ActiveXObject("Scripting.FileSystemObject");
myActiveXObject.CreateTextFile("C:\\config.xml");
file = myActiveXObject.GetFile("C:\\config.xml");
text = file.OpenAsTextStream(ForWriting, TristateFalse);
var stringText="<?xml version='1.0' encoding='utf-8'?> ";
stringText+="\n<operating_system></operating_system>\n";
text.Write(stringText);

text.Close();

xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
//xmlDoc = new ActiveXObject("MSXML2.DOMDocument");
//var xmlDoc= new ActiveXObject("Msxml2.DOMDocument.3.0");


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

//x=xmlDoc.documentElement;
var str1_prod=document.getElementById('D1').value;
var str2_test=document.getElementById('D2').value;
var str3_suit=document.getElementById('T3').value;
var str4_mac=document.getElementById('D3').value;
var str5_script=document.getElementById('T5').value;
var str6_path=document.getElementById('T4').value;
var str7_dir=document.getElementById('T2').value;
var str8_pmac=document.getElementById('D7').value;

var newel,newtext;

x=xmlDoc.getElementsByTagName('operating_system');
newel1=xmlDoc.createElement(str1_prod);
//newtext=xmlDoc.createTextNode("First");
//newel.appendChild(newtext);
x[0].appendChild(newel1);


x1=xmlDoc.documentElement.childNodes;
newel2=xmlDoc.createElement("tests");
x1[0].appendChild(newel2);


x2=xmlDoc.getElementsByTagName('tests');;
newatt2=xmlDoc.createAttribute("type");
newatt2.nodeValue=str2_test;
x2[0].setAttributeNode(newatt2);

newel4=xmlDoc.createElement("prerequisitescript");
newtext4=xmlDoc.createTextNode(str5_script);
newel4.appendChild(newtext4);
x2[0].appendChild(newel4);

newel5=xmlDoc.createElement("acbuildpath");
newtext5=xmlDoc.createTextNode(str6_path);
newel5.appendChild(newtext5);
x2[0].appendChild(newel5);

xmlDoc1=new ActiveXObject("Microsoft.XMLDOM");


xmlDoc1.async=false;
xmlDoc1.load("D:\\config_data.xml");

var str=document.getElementById('D1').value;
var str2=document.getElementById('D2').value;

var arSelected= new Array();
ob=document.getElementById('D3');
while (ob.selectedIndex != -1)
{
arSelected.push(ob.options[ob.selectedIndex].value);
ob.options[ob.selectedIndex].selected = false;
}

y=xmlDoc1.documentElement.childNodes;
for(i=0;i<arSelected.length;i++)
{
//document.write(arSelected.length);
for(k=0;k<y.length;k++)
{
if((y[k].nodeName)==str)
{
y1=y.item(k).getElementsByTagName("machine_name");

for(j=0;j<y1.length;j++)
{
//if(y1[j].hasChildNodes())
if((y1[j].text)==arSelected)
{
//document.write(y1[j].text);
//document.write("<br\>");

newel31=xmlDoc.createElement("machine_name");
newtext31=xmlDoc.createTextNode(arSelected);
newel31.appendChild(newtext31);
x1[0].appendChild(newel31);

}
}
y2=y.item(k).getElementsByTagName("vmware");


for(j1=0;j1<y2.length;j1++)
{
//if(y1[j].hasChildNodes())
if((y2.item(j1).attributes[0].value)==arSelected)
{
y5=y2[j1].text;
newel311=xmlDoc.createElement("vmware");

//newtext311=xmlDoc.createTextNode(arSelected);
newtext311=xmlDoc.createTextNode(y5);

newatt21=xmlDoc.createAttribute("id");
newatt21.nodeValue=y2.item(j1).attributes[0].value;
newel311.setAttributeNode(newatt21);


newel311.appendChild(newtext311);
x1[0].appendChild(newel311);

}
}
}
}
}

//}
newel51=xmlDoc.createElement("testsuitscript");
newtext51=xmlDoc.createTextNode(str3_suit);
newel51.appendChild(newtext51);
x2[0].appendChild(newel51);

newel52=xmlDoc.createElement("testdir");
newtext52=xmlDoc.createTextNode(str7_dir);
newel52.appendChild(newtext52);
x2[0].appendChild(newel52);


/*newel6=xmlDoc.createElement("vmware");
newtext6=xmlDoc.createTextNode(str7);
newel6.appendChild(newtext6);
x2[0].appendChild(newel6);

x3=xmlDoc.getElementsByTagName('vmware');
newatt3=xmlDoc.createAttribute("id");
newatt3.nodeValue=str3;
x3[0].setAttributeNode(newatt3);*/

xmlDoc.save("C:\\config.xml");
alert('saved');
clearlist11();
clearlist();
clearlist2();
reload();

}

If you intend serving this application to the general public, then some users, maybe the majority, will be unable to save the output automatically.

Applications like this are reall only viable in an INTRAnet environemnt where you have full knowledge and/or control of each and every client computer's configuration.

An alternative and more reliable approach would be to build your output server-side, in eg PHP, and to serve it back to the user via HTTP with an appropriate "mime-type" in the header, such that users can "save as" to his/her own HD. In other words, a dynamically generated download. That would be my first choice.

Airshow

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.