Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

html tags inside xml tags - how access in javascript?

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

like image 317
tanujdave Avatar asked Apr 24 '26 16:04

tanujdave


1 Answers

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>
like image 156
Matteo Mosca Avatar answered Apr 27 '26 10:04

Matteo Mosca