Hi there,
I want to fetch data from database ,convert it in xml then send this xml from server.In Javascript file i am trying to parse it and bind these data to some control like textbox in client page.But the xmlHttp.responseXML.documentElement returned from server is showing null:
I m using .Net,C#,(Ajax)
************************************************** ******
code snippet: serverPage.aspx.cs
************************************************** ******
SqlConnection connection=new SqlConnection(ConfigurationManager.AppSettings["connect"]);
connection.Open();
SqlDataReader dr;
SqlCommand cmd = new SqlCommand("select employeeId,employeeName,employeeDesignation,salary ,phoneNo" + " from employeeTable where employeeId=" + employeeID, connection);
dr = cmd.ExecuteReader();
if (dr.HasRows)
{
dr.Read();
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<?xml version='1.0' encoding='UTF-8'?>");
sb.Append("<Employee>");
sb.Append("<EmployeeId><![CDATA["+dr["employeeId"].ToString()+"]]></EmployeeId>");
.................................................. .................
sb.Append("("</Employee>");
Response.ContentType = "text/xml";
Response.Write(sb.ToString());
}
}
************************************************** *****************
in SelectEmployee.js
************************************************** ****************
............................
if(xmlHttp.status==200)
{
SetEmployeeLabels(xmlHttp.responseXML.documentElem ent);
}
function SetEmployeeLabels(ClientNode)
{
..................................
***************************************
this part is not working
***************************************
if(ClientNode!=null)
{
var EmployeeId=ClientNode.getElementsByTagName('Employ eeId');
var EmployeeName=ClientNode.getElementsByTagName('Empl oyeeName');
.................................................. ..........
eidTb.value=GetInnerText(EmployeeId[0]);
enameTb.value=GetInnerText(EmployeeName[0]);
.................................................. ......
}
}
function GetInnerText(node)
{
return(node.textContent||node.innerText||node.text );
}