MagpieRSS - items with the same name

Discussion in 'XML & RSS' started by Weirfire, Jun 24, 2006.

  1. #1
    I'm trying to parse a feed which uses the following format

    <feature>red</feature>
    <feature>sponge</feature>
    <feature>big</feature>

    When I parse this using Magpie RSS;

    foreach ($rss->items as $item)
    {
    $feature = $item['feature']; // Gives "redspongebig"

    }

    My question is how do I extract each feature into its own variable?
     
    Weirfire, Jun 24, 2006 IP
  2. weppos

    weppos Well-Known Member

    Messages:
    99
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    125
    #2
    Hello Weirfire,
    I don't know any valid feed with this structure.

    Could you please post a full feed code as example? :)
     
    weppos, Jun 30, 2006 IP
  3. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #3
    It was a Media RSS file. I can't post the feed because the client does not want live links to the feed.

    However I was able to parse it into arrays with simplepie. Magpie RSS bundled them all into the same variable.
     
    Weirfire, Jun 30, 2006 IP
  4. weppos

    weppos Well-Known Member

    Messages:
    99
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    125
    #4
    Ok.

    May I ask you just a piece of code instead of the link?
    I'm curious to see what kind of feed it is. :)
     
    weppos, Jun 30, 2006 IP
  5. Tim_Myth

    Tim_Myth Peon

    Messages:
    741
    Likes Received:
    52
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Its valid XML. It may not be valid RSS, Atom, or whatever, but it is valid XML. The example for XML parsing in the PHP manual has this:
    <row><entry>a1</entry><entry morerows="1">b1</entry><entry>c1</entry></row>
    <row><entry>a2</entry><entry>c2</entry></row>
    <row><entry>a3</entry><entry>b3</entry><entry>c3</entry></row>
    Code (markup):
    If you notice, each row has multiple entries. In Weirfire's example, his snippet could very well be from a larger structure like this.

    That being said, I can't even get magpie to lump them into one variable. I simply wrapped your example xml into <item> tags and nada.

    Glad to hear you got it though.
     
    Tim_Myth, Jun 30, 2006 IP
  6. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #6
    www.simplepie.org

    The guy is super helpful and will even write the code for you if you get stuck! They are writing all kinds of mods to make it parse more stuff than Magpie.
     
    Weirfire, Jun 30, 2006 IP
    Tim_Myth likes this.
  7. weppos

    weppos Well-Known Member

    Messages:
    99
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    125
    #7
    That's the point.
    MagPie is not an XML parser, is an Atom/RSS parser. ;)
     
    weppos, Jun 30, 2006 IP