-1
People need to replace tags br
for p
in my xml constructor and for this I am using the method str_replace
but he’s not making that substitution.
Follows the code:
$i=1;
foreach ($xml->channel->item as $item){
if($i <= 30){
if(substr($item->link, 0, 23) == 'https://www.site.com.br'){
$imagem = '';
if($item->images->image != ''){
$imagem = '<figure> <img src="'.str_replace(' ','',str_replace('alt=','',str_replace('"','',str_replace('src=','',str_replace('/>','',$item->images->image))))).'"/> </figure>';
}
$newItem = $newXML->addChild('item');
$newItem->addChild('title', $item->title);
$newItem->addChild('link', $item->link);
$newItem->addChild('guid', $item->guid);
$newItem->addChild('pubDate', $item->pubDate);
$newItem->addChild('content', '
<![CDATA[
<head>
<meta charset="utf-8">
<link rel="canonical" href="'. $item->link .'">
</head>
<body>
<article>
<header>
<h1>'.$item->title.'</h1>
'.str_replace('<h2></h2>','','<h2>'.$item->summary.'</h2>').'
'.$imagem.'
</header>
<!-- Article body goes here -->
'.str_replace('<br><br>','</p><p>',$item->content).'
<figure class="op-tracker">
<iframe src="https://www.site.com.br?nota=' . $item->link .'" hidden></iframe>
</figure>
<footer>
</footer>
</article>
</body>
</html>
]]> ');
$i +=1;
}}
}
print($newXML->asXML('teste.xml'));