SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Wizard Sillysoft's Avatar
    Join Date
    May 2002
    Location
    United States :)
    Posts
    1,691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Parsing XML With PHP Question

    Trying to parse information from a rss 2.0 xml document using xml_parser. Once I read the whole document I look through it using a switch, so for every TITLE echo this out. The problem is the first 2 titles are just the name of the site and not actual news.

    How would I go about skipping the first 2 to get only the news titles? I looked at the xml file and notice that the news are stored in ITEM, but no matter what I try using a switch or an if statement I cannot skip the first 2 for some reason.

    Thanks
    Silly

  2. #2
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Damn... I was looking for a similar solution in ASP and found a PHP one... can't remember the name and it was only half an hour ago! brb

  3. #3
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://www.geckotribe.com/rss/carp/

    Edit:

    Sorry. Didn't read your post properly. Still, this might help... I've been here too long, clearly, and I'm going home! Via the pub of course...

  4. #4
    Ceci n'est pas Zoef Zoef's Avatar
    Join Date
    Nov 2002
    Location
    Malta
    Posts
    1,111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What you need to to is detect if you are inside an <ITEM /> element and ignore the rest.

    This article should give you an idea: http://www.sitepoint.com/article/php...arsing-rss-1-0

    In the code of that article a global boolean variable $insideitem is used to achieve what you want. You could also wrap things in a class and use a member variable for this.

    Rik
    English tea - Italian coffee - Maltese wine - Belgian beer - French Cognac

  5. #5
    SitePoint Wizard Sillysoft's Avatar
    Join Date
    May 2002
    Location
    United States :)
    Posts
    1,691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys! I checked out both and got it to work. The second article, off of Sitepoint, I tried doing it myself from scratch before stopping due to not getting it going. I will have to look deeper at the code to see were I went wrong. But for now this will work!

    Thanks again!

    Silly

  6. #6
    Ceci n'est pas Zoef Zoef's Avatar
    Join Date
    Nov 2002
    Location
    Malta
    Posts
    1,111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're most welcome.

    You might also want to check out this: http://magpierss.sourceforge.net/

    Rik
    English tea - Italian coffee - Maltese wine - Belgian beer - French Cognac


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •