2017-10-04 49 views
1

我試圖從JSON中獲取信息,並且出現錯誤,說明我的XML格式不正確。它指向HTML/XML中的JavaScript:格式錯誤

if((jsonResponse[0].error) && (jsonResponse[0].error.type == 101)) { 
----------------------------^ 

這裏的背景:

<?xml version="1.0" encoding="UTF-8" ?> 
<!--As DOCTYPE either the strict XHTML declaration or 
    "-//HbbTV//1.1.1//EN" "http://www.hbbtv.org/dtd/HbbTV-1.1.1.dtd" 
    shall be used as described in the HbbTV-standard: A.2.6.2.--> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<!--Required XML-namespace as described in the HbbTV-standard: A.2.6.2.--> 
<html xmlns="http://www.w3.org/1999/xhtml"> 

回答

1

環繞你的JavaScript在CDATA部分,從而&&是不會被解釋爲標記:

<script> 
<![CDATA[ 
    JaveScript code here 
]]> 
</script> 
+0

,照顧您的JavaScript腳本沒有按不包含字符串']]>'。 –