473,385 Members | 2,180 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,385 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 10602
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.