2011-06-01 54 views
2

如何使用簡單的餅從s:variant模塊獲取標題標籤?用簡單的餅從原子飼料中提取<s:variant>

<s:variant> 
    <id>product_variants-96590662</id> 
    <title>Default Title</title> 
    <s:price currency="GBP">10.00</s:price> 
    <s:sku>002</s:sku> 
    <s:grams>0</s:grams> 
</s:variant> 

我試過下面來利用,同時也「變種」,只是「S」

$caption = $item->get_item_tags('http://www.w3.org/2005/Atom', 's:variant'); 

有問題的飼料here(從shopify),並在get_item_tags的文檔是here

回答

3

您可以從<feed>標記中讀取s的xml名稱空間。

<feed xmlns:s="http://jadedpixel.com/-/spec/shopify" xml:lang="en-US" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns="http://www.w3.org/2005/Atom"> 

根據它,你必須在get_item_tags()使用http://jadedpixel.com/-/spec/shopify作爲命名空間參數,第二個參數是沒有s:標籤名。

$varinat = $item->get_item_tags('http://jadedpixel.com/-/spec/shopify', 'variant'); 
+0

命名空間的URL返回404,這有什麼關係嗎? – addedlovely 2011-06-03 15:36:39

+0

shopify不再支持它們使用的命名空間。在這種情況下,即使參數現在已經很好,這種方法也可能不起作用。我會嘗試做一個完整的解析,並轉儲結果,也許你可以得到你需要的方式。 – aorcsik 2011-06-03 15:45:30

+0

嗯似乎回到我稍微更小的陣列,這是更可行。謝謝。 – addedlovely 2011-06-03 15:49:30