469,366 Members | 2,243 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,366 developers. It's quick & easy.

xmlHttp.responseXML.documentElement is returning null So unable to parse xml

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 );
}
Feb 9 '07 #1
2 10369
kenobewan
4,871 Expert 4TB
Did you receive and error? Have you tried if(!ClientNode)?
Feb 11 '07 #2
Did you receive and error? Have you tried if(!ClientNode)?
Hi there,

Thanks for looking in my problem.My problem is rectified,the problem was server side page (default.aspx)default Html content was appended to the responsexml content.
that's why it was showing Null value. in javaScript file.I removed html part in design part of server page(default.aspx) and now it is working fine.

One's Again Thanks a lot.
Ashish
Feb 13 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Nemlah | last post: by
4 posts views Thread by Sanjay Dahiya | last post: by
1 post views Thread by Dave H | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.