Click here to Skip to main content
15,895,256 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a html form in which user fills the data.
That data is shown in xml file using javascript.
Posted
v2
Comments
Shubhashish_Mandal 14-Mar-13 2:04am    
you need a xml parser to create a xml file along with the form data. I just google it with "javascript to create xml" and I get answer.
What have you tried so far ?
Post some code.
DivyaNaidu486 9-Oct-14 8:59am    
someone plz help me, i have tried this code but i am not able to generate page1.xml file,even if i create page1.xml file manually, records are not getting appended to it from html page.Thanks in advance!!!
Hi Divya,

Please add another question describing your scenario and to support that, add some code snippets.

In that way, you will get more answers. Nobody would reply here because this is one old thread.

Thanks,
Tadit
DivyaNaidu486 10-Oct-14 3:17am    
Hi Tadit,
The code i have used is
<html>
<head>
<title>Test</title>
<script type="text/javascript">
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
var fso = new ActiveXObject("Scripting.FileSystemObject");
var FILENAME = 'D:\\IE Try\\PersonXML2.xml';

function SaveXMLData() {
var file = fso.CreateTextFile('D:\\IE Try\\PersonXML2.xml', true);
file.WriteLine('<!--?xmlversion="1.0" encoding="utf-8" ?-->\n'); file.WriteLine('<personinfo>\n');

file.Write(' <Person ');
file.Write('Name="' + document.getElementById('txtname').value + '" ');
file.Write('Address="' + document.getElementById('txtadd').value + '" ');
file.Write('Address="' + document.getElementById('txtage').value + '" ');
file.WriteLine('></Person>\n');

file.WriteLine('</personinfo>\n');
file.Close();
}
</script>
</head>
<body>
Name :
<input type="text" name="name" value="" id="txtname" /><br />
Address :
<input type="text" name="id" value="" id="txtadd" /><br />
Age:
<input type="text" name="write" value="" id="txtage" /><br />
<input type="submit" onclick="SaveXMLData()" />
</body>
</html>
The above code is generating an XML file ,every time i execute the html file it generates a new xml file with one row of data in it.
I need to append data to xml file , i mean every-time i execute html file ,it should add a new row to the same xml file.
Hope you will help me out with this!!!
and thanx for your Reply.
one more thing,the above code which i have posted runs only in IE Browser, that too after making some settings in IE.
settings are
In order to run safely you need to change setting of IE.

1. Go to Tools > Internet options > Security > Custom Level
2. Under the ActiveX controls and plug-ins, select Enable for Initializing and Script ActiveX controls not marked as safe


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900