error codes for simplexml

Discussion in 'PHP' started by lruneh, Jan 23, 2009.

  1. #1
    Hi all

    I'm using simplexml to parse some feeds. Sometimes simplexml returns an error because the feeds - for whatever reason - can't be parsed by simplexml.
    What I'd like is to discard the ugly errors that simplexml returns and display a custom error in stead. Could someone please help me with that? I've tried "or die()" and if(!$xml){}

    any help would be greatly appriciated! Thanks
     
    lruneh, Jan 23, 2009 IP
  2. Panzer

    Panzer Active Member

    Messages:
    381
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Have you tried SimplePie? http://simplepie.org/ . It's essentially a framework for simplexml, makes things a whole lot easier. It can generate as well as consume RSS feeds. Theres plenty of tutorials and screencasts to help.
     
    Panzer, Jan 23, 2009 IP
  3. lruneh

    lruneh Peon

    Messages:
    72
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hey Panzer
    Thanks for your reply.
    Unfortunately I'v built up my intire site using simplexml, so converting to simplepie is not really an option for me. I could ofcourse just turn off error reporting altogether, but it would seem rather strange for visitors if a particular feed just isn't showing...
     
    lruneh, Jan 23, 2009 IP
  4. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145