<?xml version="1.0" encoding="UTF-8"?> <rss xmlns:yandex="http://news.yandex.ru" xmlns:media="http://search.yahoo.com/mrss/" version="2.0"> <channel> <title>AAA</title> <link>AAA</link> <description>AAA</description> <yandex:logo>AAA</yandex:logo> <yandex:logo type="square">AAA</yandex:logo> <item> <title>AAA/title> <link>AAA</link> <pdalink>AAA</pdalink> <description>AAA</description> <author>AAA</author> <category>AAA</category> <enclosure url="AAA" type="image/jpeg"/> <pubDate>AAA</pubDate> <yandex:full-text>AAA</yandex:full-text> </item> </channel> </rss> 

How to get from the RSS url <enclosure> and the contents of <yandex:full-text> and display all the data in foreach?

  • To use SimpleXML, it is already built into PHP, you don’t need to add anything to webmasters.by/articles/web-programming/… - boneskhv
  • This did not solve the problem. Ordinary tags I can display ... for example title, and how to get the url <enclosure> and the contents of <yandex:full-text> ?? - Denis Heavenly

1 answer 1

 # 1. Подключаем файлик. $test = simplexml_load_file("test.xml"); # 2. Получаем содержимое аттрибута url в enclosure echo $test->channel->item->enclosure->attributes()->url; # 3. Получаем содержимое yandex:full-text $namespaces = $test->getNamespaces(true); $dc = $test->channel->item->children($namespaces["yandex"]); echo $dc;