Search code examples
phpxmlscribd

quickly extract the contents of an xml tag in php


Scribd's API returns XML, for example:

<?xml version="1.0" encoding="UTF-8"?><rsp stat="ok"><thumbnail_url>http://imgv2-4.scribdassets.com/img/word_document/60906103/111x142/79c5e6bab7/1327030759</thumbnail_url></rsp>

is there a way to quickly, say in one or two lines, get the contents of thumbnail_url, that is http://imgv2-4.scribdassets.com/img/word_document/60906103/111x142/79c5e6bab7/1327030759?


Solution

  • $xml = simplexml_load_string($string_data);
    $url = (string) $xml->thumbnail_url;