3

I'm passing my xml data through php where all xml nodes are contains html tags

<bccfalna-ad>
<ad-id>99</ad-id>
<ad-title>New Ad</ad-title>
<ad-code><u><b>C Language</b></u></ad-code>

when i access this code in javascript, its easily access ad-id and ad-title but it always print null for ad-code node

var edit_ad_id = xmlDoc.getElementsByTagName("ad-id")[0].childNodes[0].nodeValue;
var edit_ad_title = xmlDoc.getElementsByTagName("ad-title")[0].childNodes[0].nodeValue;
var edit_ad_code = xmlDoc.getElementsByTagName("ad-code")[0].childNodes[0].innerHTML;

this above javascript code is used to access please help me to access html tags withing xml node....

1
  • I wouldn't have thought you'd need the childNodes[0] - var edit_ad_code = xmlDoc.getElementsByTagName("ad-code")[0].innerHTML. However, I don't think you can use innerHTML on an XML object, you would have to get all the child nodes and loop through them, re-adding the tags. Commented Sep 17, 2010 at 11:36

1 Answer 1

4

You should wrap the contend of your xml node with a CDATA block like this:

<ad-code><![CDATA[<u><b>C Language</b></u>]]></ad-code>
Sign up to request clarification or add additional context in comments.

1 Comment

Happy to have helped you. Remember to mark as anwser the post that helped you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.