SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Condition to check XML feeds

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    May 2007
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Condition to check XML feeds

    Hello everyone, I am trying to create a condition to check if a users blog feed is working based on the URI they submit. This is what I'm working with and when the URI is not a correct feed, I get this: Warning: xml_parse() [function.xml-parse]: Unable to call handler cdataHandler() in /options.php on line 46

    PHP Code:
    $uri "http://www.example.com";

    if( 
    $fp = @fopen($uri"r"))
    {
        
    $parser xml_parser_create();
        
    xml_set_object($parser$this);
        
    xml_parser_set_option($parserXML_OPTION_CASE_FOLDING1);
        
    xml_set_character_data_handler($parser"cdataHandler");
        
    xml_set_element_handler($parser"startElementHandler""endElementHandler");

        while(
    $xml fread($fp4096))
        {
            if(!
    xml_parse($parser$xmlfeof($fp)))
            {
                
    $error "XML ERROR: " xml_error_stringxml_get_error_code($parser)) . " at line " xml_get_current_line_number($parser);
            }
        }

        
    xml_parser_free($parser);

        
    fclose($fp);
        
        echo 
    "a working feed!";
    }
    else
    {
        echo 
    "not a working feed!";

    How will I be able to check if a users URI is actually a real feed? Thank!

  2. #2
    SitePoint Member
    Join Date
    May 2007
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was told that I could probably use DOM to verify the XML structure as valid in php5. Is this true? If so, is there a reference I can check out? Thanks.

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
  •