这是我的表单.html代码所有值通过javascript以xml格式写入
<form id='mrgv"+i+"'>
<table class='propform'>
<tr><td colspan='2'><b>Visual Properties</b></td></tr>
<tr><td>Name</td><td><input type='text' id='delimitDatanameVisual'></td></tr>
<tr><td>Description</td>
<td><input type='text' id='delimitDatadescVisual'></td></tr>
<tr><td colspan='2'><b>Rule Engine Properties</b></td></tr>
<tr><td>1. Id </td>
<td> <input type='text' id='delimitDataidValue'/></td></tr>
<tr><td>2. Phase No: </td>
<td><input type='text' id='delimitDataphaseNo'/></td></tr>
<tr><td>3. KeyFields:</td><td><input type='text' id='delimitDatafileurl' /></td>
<td><select id='delimitDataabs'>
<option value='abs'>abs</option>
<option value='ph'>ph</option></tr>
<tr><td>4. OPR Flag: </td>
<td><select id='delimitDataencoding'>
<option value='Inner'>Inner</option>
<option value='LeftOuter'>LeftOuter</option>
<option value='Duplicate'>Duplicate</option>
<option value='RightOuter'>RightOuter</option>
</select></font></td></tr>
<tr><td>5. OutFlag:</td>
<td><input type='text' id='outmv' /></td>
<td><select id='delimitDataabs'>
<option value='abs'>abs</option>
<option value='ph'>ph</option>
</tr>
</table>
这是我的javascript,它将上面的表单值写入xml
function mrgv(i)
{
var object = new ActiveXObject("Scripting.FileSystemObject");
var file = object.OpenTextFile("D:\\vyas\\hello.grf",8,true,0);
var mrgvform=document.getElementById("mrgv"+i);
var idValue = mrgvform.delimitDataidValue.value;
var phaseNo = mrgvform.delimitDataphaseNo.value;
var keyfields=mrgvform.delimitDatafileurl.value;
var oprflag =mrgvform.delimitDataencoding;
var oprflagg = oprflag.options[oprflag.selectedIndex].text;
var outflag =mrgvform.outmv.value;
//file.WriteLine("<graph>");
file.WriteLine("<Node" + " id=\"" + idValue +"\" "+ "" + "type=\"MERGE_V\" "+ " " + "Phase No=\""+ phaseNo +"\" "+ " " + "keyfields=\"" + keyfields +"\" " + " " + "oprflag=\"" + oprflagg +"\" " + "" + "outflag=\"" + outflag +"\" " + " ></Node>" );
//file.WriteLine("</graph>");
file.Close();
}
我的问题是:我想将所有值重定向到xml。已完成。如果再次从表单提交值而不是其附加到下一行,但我想在现有值上覆盖该值。
答案 0 :(得分:0)
我认为您希望每次都使用新值覆盖XML文件,而不是像日志文件那样附加。您正在使用append方法写入文件,因此它不会清除现有内容。
// you should delete the `D:\\vyas\\hello.grf` file here so it
// is re-created as an empty file on the next line
var file = object.OpenTextFile("D:\\vyas\\hello.grf",8,true,0);