473,390 Members | 1,235 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,390 software developers and data experts.

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 10603
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Nemlah | last post by:
Hello, I am working on a site which utilizes PHP/JS and the new found XMLHTTP frenzy to update dynamically. WHile the whole mechanism works beautifull, i can't get to display greek Characters...
2
by: mikeyjudkins | last post by:
Ive been banging my head on the wall for hours with this one, hopefully someone will know what Im doing wrong here :\ The Goal: I have an xml file that is generated on the fly via JSP which I...
5
by: dandiebolt | last post by:
Using xmlhttp I am accessing a document from the web that is not xml and is in fact not even proper html even though it is supposed to be (unbalanced tags). Here is the type of code I am using: ...
4
by: Sanjay Dahiya | last post by:
I tried POSTing from XMLHttpRequest, i can get the XML right on server but responseXML from server is coming null. I can see the XML right in responseText. but responseXML is null. responseText to...
1
by: Dave H | last post by:
First.. What object (on the client) should I be using these days? var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); or var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); or maybe...
3
by: Noozer | last post by:
Hrm.. last posting was mangled. Let's try again, with more detail... I'm just starting to try out "Ajax" web programming and I've got a question. AJAX is fairly straightforward. Javascript...
4
by: sirjohnofthewest | last post by:
If I possessed the power to sway the mind of every user in the world to delete all forms of Internet Explorer I would die a happy man. Hi guys, I frequently visit this site to get answers to my...
1
by: Sand Yaah | last post by:
i went thru a discussion put by eros and helped out by dmjpros. d questions asked were right and i tried each but there was no problem there. my code returns null in xmlHttp.responseXML and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.