Quick question regarding parsing XML feed

Status
Not open for further replies.

nogenius

likes money
Mar 16, 2007
487
3
0
Texas
Hello,

I currently have an XML feed (that I can get in either Atom or RSS 2.0 format), that I wish to extract title and description information from each entry and place that data into a text file.

I've done some preliminary research into this and found out about the expat PHP library - but it seems a bit complicated, is there an easier method I could go about doing this?

Any help would greatly appreciated.
 


Regular expressions will do it. But they can be a bit daunting at first.
 
Its actually pretty easy when you take a second to look at it and not be intimidated by it.

Code:
$data = implode("", file($filename));
   $parser = xml_parser_create();
   xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
   xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
   xml_parse_into_struct($parser, $data, $values, $tags);
   xml_parser_free($parser);

I would probably stay away from the implode function though and go with cURL.
 
Regular expressions will do it. But they can be a bit daunting at first.

If you don't like the php crap I gave you to examine (which only points you in the right direction and is not a guide), you could get familiar with regular expressions and strip out the unwanted elements in an XML doc.

EDIT: If its only one and you don't like code why not just right click, copy, then paste elsewhere.
 
Magpie has worked great for me in the past as well. If you have php5, you have a few xml options as well, simpleXML being my favorite. Regular expressions are also an option, but if you're dealing with formatted RSS feeds and just need to get data from tags I don't know if they're worth the trouble.

Magpie for out of the box, simpleXML if you wan't to get your hands dirty.
 
Status
Not open for further replies.