PDA

View Full Version : how to update a xml file from the database values



anishtomas
10-07-2008, 05:24 AM
well wht my program suppose to do is...like my jsp file should get some values from database(sql server 2000) and update these values into xml file......
Code:


<%@ page language="java" import="java.lang.*"%>
<%@ page language="java" import="java.io.*" %>
<%@ page language="java" import="java.util.*" %>
<%@ page language="java" import="java.net.*" %>

<% String contextPath = request.getContextPath();

System.out.println("context path is"+contextPath);

%>




<SCRIPT LANGUAGE=javascript>
<!--

function fnValidateUser()
{

var frm=document.postXml.username.value;
alert("username is")
alert(frm)
if (frm == "")
{
alert("Please enter username!");
frm.focus();
return false;
}


var xmlDoc,strSname, strmodel,strStatus;
alert("1")
var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
alert("1")
alert("sdsd"+xmlDoc)
xmlDoc.load("<%=contextPath%>/jsp/Reporting/storedata.xml");
objxmlfn = xmlDoc.getElementsByTagName("UserName")
alert("pathis"+objxmlfn)
objxmlfn.item(0).text = frm
FileSysObj=new ActiveXObject("Scripting.FileSystemObject");
WriteTextStream=FileSysObj.OpenTextFile("<%=contextPath%>/jsp/Reporting/storedata.xml",2,true);
WriteTextStream.Write(xmlDoc.documentElement.xml);
WriteTextStream.Close();
window.location.reload()
//window.location.href = "../NE_Services/NE_Services_Manage.html"

}
//-->
</SCRIPT>

<html>

<head>

<title></title>

</head>

<body>



<form name="postXml">
Username <input name="username" type="text">

<input name="submit" id="submit" type="button" value="submit" onclick="fnValidateUser()">
</form>
</body>

</html>


but when i run the program i'm getting the error path not found....any help will be appreciated...(or someone can suggest any alternate method also)