How to extract deeper elements? #10

Closed
nfitzpatrick opened this Issue Dec 13, 2012 · 2 comments

Comments

Projects
None yet
2 participants

I am having trouble getting the following values from my XML file:

  1. media:content.duration
  2. media:group > media:content.bitrate
  3. media:group > media:content.expression
  4. media:category

Any help will be appreciated.

Sample from my XML file

<item>
        <title>dom cuce</title>
        <description>Dominick Cuce of Old Bridge discusses his team&amp;apos;s 5-1 victory over Woodbridge</description>
        <guid>video2031742630001</guid>
        <pubDate>Wed, 12 Dec 2012 16:53:29 -0800</pubDate>
        <media:content duration="39" medium="video" type="video/mp4" url="http://www.domain.com"/>
        <media:group>
            <media:content bitrate="684" expression="full" />
        </media:group>
        <media:category>Most Recent Videos</media:category>
    </item>

My working code

this works but I don't know how to get the four elements listed above

SMXMLElement *channel = [document.root childNamed:@"channel"];
for (SMXMLElement *item in [channel childrenNamed:@"item"])
{
NSString *guid = [item valueWithPath:@"guid"];
NSString *title = [item valueWithPath:@"title"];
NSString *description = [item valueWithPath:@"description"];
NSString *pubDate = [item valueWithPath:@"pubDate"];
}

Owner

nfarina commented Dec 13, 2012

Hello,

So SMXMLDocument can handle XML elements with namespaces (like your media: namespace), but discards them entirely after parsing. So what you're looking for is:

[item valueWithPath:@"category"];

Instead of specifying @"media:category".

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment