Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Extracting a value from an XML result WordPress


Given an XML result such as that seen at [[LINK href=""]][[/LINK]] how is it best to extract and echo the 'like_count' value? Thanks.

Answers (2)


Gabriel Reguly answers:

Use [[LINK href=""]][[/LINK]]

designbuildtest comments:

Thanks Gabriel, not really a complete answer, but it did lead me to [[LINK href=""]]this entry on StackOverflow[[/LINK]] which in turn enabled me to produce:

$url = '';
$response = wp_remote_get( $url );
$body = wp_remote_retrieve_body( $response );
$xml = simplexml_load_string( $body );
$like_count = $xml->link_stat->like_count;

echo $like_count;

designbuildtest comments:

Marking this one as solved. Thanks Gabriel.


Arnav Joy answers:

what is the output of this


$xml = simplexml_load_string("");
if ( $xml ) {


designbuildtest comments:

Produces an error message unfortunately ... simplexml_load_string(): Entity: line 1: parser error