2009-10-29 56 views
2

下面的代碼:FBML和HTMLParser的錯誤

<html xmlns="http://www.w3.org/1999/xhtml" 
     xmlns:fb="http://www.facebook.com/2008/fbml" 
     xml:lang="en" lang="en"> 
<head> 
    <title>FB Test</title> 
</head> 

<body> 
    <a href="#" onclick="FB.Connect.inviteConnectUsers();">Test</a> 
    <fb:serverfbml style="width: 350px;"> 
     <script type="text/fbml"> 
      <fb:connect-form action="http://127.0.0.1/post_invite">  
      </fb:connect-form> 
     </script> 
    </fb:serverfbml> 
</body> 
</html> 

結果在以下錯誤:

- Warning: Compilation failed 
    - Warning: <class 'zope.tal.htmltalparser.NestingError'>: Open tags <html>, <body>, <fb:serverfbml>, <script> do not match close tag </fb:connect-form>, at line 16, column 4 
PTRuntimeError: ['Compilation failed', u"<class 'zope.tal.htmltalparser.NestingError'>: Open tags <html>, <body>, <fb:serverfbml>, <script> do not match close tag </fb:connect-form>, at line 16, column 4"] 

然而,結構似乎有效,我...

回答

2

您不能將標籤放在<script>標籤內,嚴格的ZPT解析器正在抱怨這一點。您必須以某種方式轉義內容,如使用tal:content =「structure string:」構造:

<script type="text/fbml" tal:content="structure string: 
    &lt;fb:connect-form action=&quot;http://127.0.0.1/post_invite&quot;&lt;   
    &gt;/fb:connect-form&lt; 
"></script> 
0

腳本變量不能包含我的知識xml。

您可以將內容封裝在xml註釋中,看看是否有效。