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?
Hello Weirfire, I don't know any valid feed with this structure. Could you please post a full feed code as example?
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.
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.
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.
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.