Adding xml into html

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
shawngoldw
Forum Contributor
Posts: 212
Joined: Mon Apr 05, 2010 3:38 pm

Adding xml into html

Post 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
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: Adding xml into html

Post by Jade »

You can do that using:

Code: Select all

document.getElementByID("description").innerHTML = "blah blah <b>blah</b> blah";
shawngoldw
Forum Contributor
Posts: 212
Joined: Mon Apr 05, 2010 3:38 pm

Re: Adding xml into html

Post by shawngoldw »

Thanks, but that does not seem to work with the xml dom
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: Adding xml into html

Post 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.
Post Reply