里面的XML标记HTML标签 - 如何获得在JavaScript? [英] html tags inside xml tags - how access in javascript?
本文介绍了里面的XML标记HTML标签 - 如何获得在JavaScript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我通过PHP通过我的XML数据,所有的XML节点都包含HTML标记
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>
当我访问此code在JavaScript中,其轻松地访问广告ID和广告标题,但它总是打印为null,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;
这上面的JavaScript code用于访问,请帮助我访问HTML标签withing XML节点....
this above javascript code is used to access please help me to access html tags withing xml node....
推荐答案
您应该换你的XML节点的用CDATA块这样的主张:
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>
这篇关于里面的XML标记HTML标签 - 如何获得在JavaScript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文