如何添加两个XMLNS代码?

时间:2012-06-28 01:09:27

标签: xml xml-namespaces

我已经添加了一个fb xmlnx代码,如下所示,现在我再添加另一个。

<html xmlns:fb='http://www.facebook.com/2008/fbml'>

当我在下面添加时,它显示错误,

    <html 
xmlns:fb='http://www.facebook.com/2008/fbml'
xmlns:fb='http://ogp.me/ns/fb#'>

任何人都可以告诉我如何添加两个代码???

1 个答案:

答案 0 :(得分:3)

一般答案:

无法“连接”命名空间,但您可以为它们提供不同的前缀

    <html 
          xmlns:fb='http://www.facebook.com/2008/fbml'
          xmlns:og='http://ogp.me/ns/fb#'>

然后使用fb:tag作为facebook标签,使用og:tag作为ogp.me标签

具体答案:

建议使用Open Graph协议不是通过xmlns属性,而是通过前缀属性(http://ogp.me/)所以使用两者的代码将如下所示:

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"
      xmlns:fb="https://www.facebook.com/2008/fbml"> 
<head prefix="og: http://ogp.me/ns# [YOUR_APP_NAMESPACE]: 
                  http://ogp.me/ns/apps/[YOUR_APP_NAMESPACE]#">
  <meta property="fb:app_id" content="[YOUR_APP_ID]" /> 
  <meta property="og:type" content="[YOUR_APP_NAMESPACE]:recipe" /> 
  ...

https://developers.facebook.com/docs/opengraph/tutorial/

提供的示例
相关问题