0

I'm looking for a way to receive a XML Element (the id of an entry) from a YouTube feed (e.g. http://gdata.youtube.com/feeds/api/users/USERNAME/uploads).

The feed looks like this:

<feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:gd="http://schemas.google.com/g/2005" xmlns:yt="http://gdata.youtube.com/schemas/2007" gd:etag="W/&quot;DUcFQncyfCp7I2A9WhVUFE4.&quot;">
<id>tag:youtube.com,2008:user:USERNAME:uploads</id>
<updated>2012-05-19T14:16:53.994Z</updated>
  ...
    <entry gd:etag="W/&quot;DE8NSX47eCp7I2A9WhVUFE4.&quot;">
        <id>tag:youtube.com,2008:video:MfPpj7f6Jj0</id>
        <published>2012-05-18T13:30:38.000Z</published>
  ...

I want to get the first tag in entry (tag:youtube.com, 2008 ...).

After googling for some hours and looking through the GDataXML wiki, I'm clueless because neither XPath nor GData could deliver the right element. My first guess is, they can't ignore the attributes in the feed and entry tags.

A solution using XPath would be great, but one in Objective-C is equally welcome.

  • 1
    Is there only one `entry`? Or do you care which `entry`? Do you want the `id`s of all `entry`s? What did you try and how did it fail? – Ken Thomases May 19 '12 at 16:36

1 Answers1

1

You might be having an issue trying to get XPath to work because of the default namespace.

If you just want the first tag in entry, you can use this:

/*/*[name()='entry']/*[1]

If you want the first id specifically, you can use this:

/*/*[name()='entry']/*[name()='id'][1]

Also if you can use XPath 2.0, you can skip the predicate entirely and use * for the namespace prefix:

/*/*:entry/*:id[1]
Daniel Haley
  • 51,389
  • 6
  • 69
  • 95