2

How can I get the title tag from the s:variant block below using simple pie?

<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>

I've tried the following to avail, and also 'variant' and just 's'

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

The feed in question is here (from shopify), and the docs on get_item_tags is here.

Dan Lowe
  • 51,713
  • 20
  • 123
  • 112
addedlovely
  • 3,076
  • 3
  • 22
  • 37

1 Answers1

3

You can read the xml namespace for s from the <feed> tag.

<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">

According to it you have to use http://jadedpixel.com/-/spec/shopify as the namespace parameter in get_item_tags(), and the second parameter is the tag name without the s:.

$varinat = $item->get_item_tags('http://jadedpixel.com/-/spec/shopify', 'variant');
aorcsik
  • 15,271
  • 5
  • 39
  • 49
  • The URL for the namespace returns a 404, does that matter? – addedlovely Jun 03 '11 at 15:36
  • There is a chance that the namespace they use is no longer supported by shopify. In that case this method may not work, even if the parameters are good now. I would try doing a full parse, and dump the result, maybe you can get what you need that way. – aorcsik Jun 03 '11 at 15:45
  • Hmm seems to chuck me back a slightly smaller array, which is more workable. Thanks. – addedlovely Jun 03 '11 at 15:49