Answer the question
In order to leave comments, you need to log in
How to parse png?
There is such xml parsing
<?php
$url = 'http://site.ru/sitemap.xml';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'app');
$query = curl_exec($ch);
curl_close($ch);
$xml=simplexml_load_string($query);
//$xml = str_replace('€', '€', $xml);
?>
<table width=100%>
<tr bgcolor="#CAE8F0" align="left">
<td><b><?= $xml->offer[1]['title']?></b></td>
<td width=5%><b><a href="<?=$xml->offer[1]["href"]?>">buy</a></td>
</tr>
</table>
Answer the question
In order to leave comments, you need to log in
Maybe I didn’t quite understand the task, but if there is only one picture, it is always in PNG, then why not run $xml through preg_match using the regular expression /site\.ru\/[a-zA-Z0-9]+.png/
if (preg_match("/site\.ru\/[a-zA-Z0-9]+.png/", $xml, $matches) {
$image = $matches[0];
} else {
echo "Изображение по шаблону не найдено";
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question