Page 1 of 1

Adding xml into html

Posted: Fri Jun 03, 2011 4:33 pm
by shawngoldw
I have some xml which I've received from an AJAX request. Say it looks like this:

Code: Select all

<descriptions>
  <myDescription>this is a description. Maybe their is some <b>html</b> in here.</myDescription>
</descriptions>
In my html I have a div which we will call:

Code: Select all

<div id="description">
</div>
I want to insert the contents of <myDescription> into description to become:

Code: Select all

<div id="description">
    this is a description. Maybe their is some <b>html</b> in here.
</div>
I'm able to traverse through the xml response but I've been unable to insert the HTML contents of the node into my div. Any help would be appreciated.

Thanks,
Shawn

Re: Adding xml into html

Posted: Tue Jun 07, 2011 9:42 am
by Jade
You can do that using:

Code: Select all

document.getElementByID("description").innerHTML = "blah blah <b>blah</b> blah";

Re: Adding xml into html

Posted: Sat Jun 11, 2011 10:41 am
by shawngoldw
Thanks, but that does not seem to work with the xml dom

Re: Adding xml into html

Posted: Wed Jun 22, 2011 8:12 pm
by Jade
Then you'll have to parse the reply and add it in there manually. Even if you're using Jquery I don't think they have something to handle that kind of situation.