Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am attempting to build out a dashboard widget that will perform a validation check on a site RSS feed using the W3 Validator. Their API docs (http://feed2.w3.org/docs/soap.html) provide the method. Here is my function to get the data:

    $feed       = 'http://domain.com/feed/';
    $request    = new WP_Http;
    $url        = 'http://validator.w3.org/feed/check.cgi?url='.urlencode($feed).'&output=soap12';
    $response   = wp_remote_get ( $url );


    if( is_wp_error( $response ) ) {
        echo '<p>Sorry, there was an error with your request.</p>';
    } else {
        $feed_data  = $response['body'];
    }

Here is the return: http://pastie.org/4397488

For the life of me, I cannot seem to parse out that XML properly. Is there a 3rd party library I should be using, or is there a native WP function that will handle this?

share|improve this question
    
This seems more like a general PHP question, not a WP question. PHP has built XML parsing facilities: php.net/manual/en/book.xml.php –  chrisguitarguy Aug 6 '12 at 4:34
    
I understand its PHP related, however, I'm doing it within WP and I want to stick with native WP functionality if at all possible –  Norcross Aug 6 '12 at 12:10
add comment

1 Answer

up vote 5 down vote accepted

Lots of places in WordPress use xml_parse including the Atom library, the XML-RPC Library that we use, and SimplePie

The oembed class uses SimpleXML.

The WordPress Importer and Jetpack actually use both (Jetpack for different things, and the importer tries to use SimpleXML and falls back if it doesn't exist).

Basically, there's nothing built into WordPress, it just uses what's built into PHP. I personally like (and use) SimpleXML as long as the XML isn't going to be too big (I mean really big), just because you can simply pass the whole XML string to it and get back an object you can work with.

share|improve this answer
    
Thanks man. passing the response into a string with simplexml_load_string was the piece I was missing –  Norcross Aug 6 '12 at 15:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.