2010-07-15 65 views
0

UPDATE:XML分析器錯誤:此代碼有什麼問題?

嗨,

我已經縮小的問題(S)和它似乎是在這部分代碼:

<script type="text/javascript"> 
oxm_ad = {"website":"cca5e4b8-7ed2-848b-ffea-037efaac851a", 
"size":"468x60", 
"floor":"0.1", 
"beacon":"<div id='beacon_f936906f11' style='position: absolute; left: 0px; top: 0px; visibility: hidden;'><img src='http:\/\/www.mywebsite.com\/openx\/www\/delivery\/lg.php?bannerid=1&amp;campaignid=1&amp;zoneid=4&amp;loc=http%3a%2f%2flocalhost%2fproperty-debug%2fproperty.html&amp;cb=f936906f11&amp;bannerid=-1' width='0' height='0' alt='' style='width: 0px; height: 0px;' \/><\/div>", 
"fallback":"<a href='http:\/\/www.mywebsite.com\/openx\/www\/delivery\/ck.php?oaparams=2__bannerid=1__zoneid=4__cb=f936906f11__oadest=http%3a%2f%2fwww.mywebsite.com' target='_blank'><img src='http:\/\/www.mywebsite.com\/openx\/www\/delivery\/ai.php?filename=mybanner.png&amp;contenttype=png' width='468' height='60' alt='' title='' border='0' \/><\/a><div id='beacon_f936906f11' style='position: absolute; left: 0px; top: 0px; visibility: hidden;'><img src='http:\/\/www.mywebsite.com\/openx\/www\/delivery\/lg.php?bannerid=1&amp;campaignid=1&amp;zoneid=4&amp;loc=http%3a%2f%2flocalhost%2fproperty-debug%2fproperty.html&amp;cb=f936906f11' width='0' height='0' alt='' style='width: 0px; height: 0px;' \/><\/div>"}; 
</script> 

謝謝。

-Laxmidi


嗨,

我收到提示1090,XML解析器錯誤。我的代碼是:

<adXMLReturn><script type="text/javascript"><!--//<![cdata[ 
    var m3_u = (location.protocol=='https:'?'https://www.mywebsite.com/openx/www/delivery/ajs.php':'http://www.mywebsite.com/openx/www/delivery/ajs.php'); 
    var m3_r = math.floor(math.random()*99999999999); 
    if (!document.max_used) document.max_used = ','; 
    document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u); 
    document.write ("?zoneid=4"); 
    document.write ('&amp;cb=' + m3_r); 
    if (document.max_used != ',') document.write ("&amp;exclude=" + document.max_used); 
    document.write (document.charset ? '&amp;charset='+document.charset : (document.characterset ? '&amp;charset='+document.characterset : '')); 
    document.write ("&amp;loc=" + escape(window.location)); 
    if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer)); 
    if (document.context) document.write ("&context=" + escape(document.context)); 
    if (document.mmm_fo) document.write ("&amp;mmm_fo=1"); 
    document.write ("'><\/scr"+"ipt>"); 
//]]>--></script><script type="text/javascript" src="http://www.mywebsite.com/openx/www/delivery/ajs.php?zoneid=4&amp;cb=87015091150&amp;charset=utf-8&amp;loc=http%3a//localhost/property-debug/property.html"></script><script type="text/javascript"> 
oxm_ad = {"website":"cca5e4b8-7ed2-848b-ffea-037efaac851a", 
"size":"468x60", 
"floor":"0.1", 
"beacon":"<div id='beacon_f936906f11' style='position: absolute; left: 0px; top: 0px; visibility: hidden;'><img src='http:\/\/www.mywebsite.com\/openx\/www\/delivery\/lg.php?bannerid=1&amp;campaignid=1&amp;zoneid=4&amp;loc=http%3a%2f%2flocalhost%2fproperty-debug%2fproperty.html&amp;cb=f936906f11&amp;bannerid=-1' width='0' height='0' alt='' style='width: 0px; height: 0px;' \/><\/div>", 
"fallback":"<a href='http:\/\/www.mywebsite.com\/openx\/www\/delivery\/ck.php?oaparams=2__bannerid=1__zoneid=4__cb=f936906f11__oadest=http%3a%2f%2fwww.mywebsite.com' target='_blank'><img src='http:\/\/www.mywebsite.com\/openx\/www\/delivery\/ai.php?filename=mybanner.png&amp;contenttype=png' width='468' height='60' alt='' title='' border='0' \/><\/a><div id='beacon_f936906f11' style='position: absolute; left: 0px; top: 0px; visibility: hidden;'><img src='http:\/\/www.mywebsite.com\/openx\/www\/delivery\/lg.php?bannerid=1&amp;campaignid=1&amp;zoneid=4&amp;loc=http%3a%2f%2flocalhost%2fproperty-debug%2fproperty.html&amp;cb=f936906f11' width='0' height='0' alt='' style='width: 0px; height: 0px;' \/><\/div>"}; 
</script> 
<script type="text/javascript" src="http://bid.openx.net/jstag"></script><script type="text/javascript" src="http://bid.openx.net/json?c=oxm_72123972249&amp;pid=cca5e4b8-7ed2-848b-ffea-037efaac851a&amp;s=468x60&amp;f=0.1&amp;url=http%3a%2f%2flocalhost%2fproperty-debug%2fproperty.html"></script><a href="http://www.mywebsite.com/openx/www/delivery/ck.php?oaparams=2__bannerid=1__zoneid=4__cb=f936906f11__oadest=http%3a%2f%2fwww.mywebsite.com" target="_blank"><img src="http://www.mywebsite.com/openx/www/delivery/ai.php?filename=mybanner.png&amp;contenttype=png" alt="" title="" border="0" height="60" width="468"></img></a><div id="beacon_f936906f11" style="position: absolute; left: 0px; top: 0px; visibility: hidden;"><img src="http://www.mywebsite.com/openx/www/delivery/lg.php?bannerid=1&amp;campaignid=1&amp;zoneid=4&amp;loc=http%3a%2f%2flocalhost%2fproperty-debug%2fproperty.html&amp;cb=f936906f11" alt="" style="width: 0px; height: 0px;" height="0" width="0"></img></div></adXMLReturn> 

當我在瀏覽器中打開這個代碼,我得到:

此頁面包含以下錯誤:

1號線誤差在列1543:錯誤解析屬性名 下面是頁面的渲染到第一個錯誤

oxm_ad = {"website":"cca5e4b8-7ed2-848b-ffea-037efaac851a", "size":"468x60", "floor":"0.1", "beacon":" 

有誰知道這個問題可能是什麼?

謝謝!

-Laxmidi

回答

0

好的,我明白了。問題在於我提到的腳本塊。我不得不撕掉所有的黑點。

謝謝大衛和邁克爾的投入。

校正位的樣子:

<script type="text/javascript"> 
oxm_ad = {"website":"cca5e4b8-7ed2-848b-ffea-037efaac851a", 
"size":"468x60", 
"floor":"0.1", 
"beacon":"<div id='beacon_f936906f11' style='position: absolute; left: 0px; top: 0px; visibility: hidden;'><img src='http://www.mywebsite.com/openx/www/delivery/lg.php?bannerid=1&amp;campaignid=1&amp;zoneid=4&amp;loc=http%3a%2f%2flocalhost%2fproperty-debug%2fproperty.html&amp;cb=f936906f11&amp;bannerid=-1' width='0' height='0' alt='' style='width: 0px; height: 0px;' /></div>", 
"fallback":"<a href='http://www.mywebsite.com/openx/www/delivery/ck.php?oaparams=2__bannerid=1__zoneid=4__cb=f936906f11__oadest=http%3a%2f%2fwww.mywebsite.com' target='_blank'><img src='http://www.mywebsite.com/openx/www/delivery/ai.php?filename=mybanner.png&amp;contenttype=png' width='468' height='60' alt='' title='' border='0' /></a><div id='beacon_f936906f11' style='position: absolute; left: 0px; top: 0px; visibility: hidden;'><img src='http://www.mywebsite.com/openx/www/delivery/lg.php?bannerid=1&amp;campaignid=1&amp;zoneid=4&amp;loc=http%3a%2f%2flocalhost%2fproperty-debug%2fproperty.html&amp;cb=f936906f11' width='0' height='0' alt='' style='width: 0px; height: 0px;' /></div>"}; 
</script> 
0

XML區分大小寫。嘗試使用CDATA而不是cdata

+0

,你可能想要把''在你的第二個腳本標籤的內容<![CDATA ['...']!>。 XML解析器可能會阻塞那裏的標籤。 – Michael 2010-07-15 19:08:34

0

你有style='width: 0px; height: 0px;' \/>\是不是在XML有效的屬性。

這裏真正的問題是,你想要的腳本元素(或可能的adXMLReturn元素的全部內容)的內容被視爲文本,你是不是正確編碼它。

如果你想要的東西作爲文本處理,那麼你需要:

  1. 特殊字符進行編碼(即<&>應分別爲&lt;&amp;&gt;
  2. 將它們標記爲CDATA

請注意,您不能嵌套CDATA節,因此如果y您希望將整個內容視爲文本,您需要更改第一個腳本或使用第一個腳本。

如果使用XML工具,而不是通過手工或使用模板構建XML,那麼它會照顧一切爲您服務。

在第一個劇本的主題,那是相當的時刻打破。除非你真的想其註釋掉刪除<!---->。你可能想看到Comments and CDATA更多關於該主題。

+0

嗨大衛, 謝謝你的留言!我真的在這一塊上敲了敲頭。該代碼由另一家公司生成,我必須讓它與我的網站一起工作。所以,我正在嘗試編寫替換語句以將其轉換爲正確的格式。如果你看到其他我可以嘗試的東西,請告訴我。 非常感謝。 – Laxmidi 2010-07-15 19:54:10

+0

第三方提供psuedo-XML時總是很棒。我首先向他們報告錯誤,並看看他們是否可以解決這個問題。否則,試圖預處理它以消除錯誤可能是您的最佳選擇。 – Quentin 2010-07-15 20:15:31

+0

嗨大衛, 完全同意你的看法。不幸的是,他們不會改變代碼,所以我現在正在進行預處理。 再次感謝您的幫助。 – Laxmidi 2010-07-15 22:11:32