Click to See Complete Forum and Search --> : ajax and XML


stevanicus
12-29-2007, 12:23 PM
Hi,

I have a simple bloging/comments system that has a form - this form then uses an xmlHttp request, where my asp file extracts data from my database and creates an xml form.

However Im having problems controlling the output of the database. I want it to display everything with is does according to the SQL query. however i might want to display certain things in different ways e.g. bold italic etc.

However it just displays it in one big set and i can touch any of the data.

what am i doing wrong? and what do i need to be looking into?? thanks

stevanicus

function blog()
{
var xmlDoc=xmlHttp.responseXML.documentElement;
document.getElementById("tBlog").innerHTML=xmlHttp.responseText;
document.getElementById("bgId").innerHTML=
xmlDoc.getElementsByTagName("blogId")[0].childNodes[0].nodeValue;
document.getElementById("bgbody").innerHTML=
xmlDoc.getElementsByTagName("blogBody")[0].childNodes[0].nodeValue;
document.getElementById("bgmadeBy").innerHTML=
xmlDoc.getElementsByTagName("blogAuthor")[0].childNodes[0].nodeValue;
}


<div id="tBlog">
<b><span id="bgId"></span></b><br />
<span id="bgbody"></span><br />
<span id="bgmadeBy"></span>
</div>


thanks again

jkmyoung
01-03-2008, 01:58 PM
You could do something like

document.getElementById("bgbody").innerHTML=
"<i>"+
xmlDoc.getElementsByTagName("blogBody")[0].childNodes[0].nodeValue+
"</i>";

Is that what you had in mind?