【发布时间】:2016-07-25 07:36:28
【问题描述】:
我正在尝试将各种 xml 数据加载到 html。在其他数据中,我有背景图像的路径。 xml 加载正常,但我得到一个空格,它将我的路径与 bg 图像 (d_onkey) 分开。 xml 文件中没有空格。任何想法来自哪里?
xml 示例
<event id="event104">
<img>images\donkey_fest.jpg</img>
<title>test</title>
<type>Cultural</type>
<date>Friday 25/5/16</date>
<time>19:30-01:30</time>
<place>Stadium</place>
<area>Limassol</area>
<description>some text</description>
<url>http://www.thevillagexpress.com/cyprusvillage/profile/209&lang=gr</url>
</event>
html代码
document.getElementById("event_banner").style.backgroundImage = "url("+
x[i].getElementsByTagName("img")[0].childNodes[0].nodeValue + ")" ;
html 结果
<div style="background-image: url("images\d onkey_fest.jpg");" class="event_banner" id="event_banner">
</div>
谢谢。
【问题讨论】:
标签: javascript html xml dom