简体   繁体   English

提取 <SONGTITLE /> ShoutCast V2 xml中的一行

[英]Extract <SONGTITLE /> line from ShoutCast V2 xml

Good, I have this echo php code that tries to extract from Shoutcast v2 XML the line "SONGTITLE", but I'm not getting it, I get an error and I come to help if you can detect the error that I change more lines I'm not to achieve. 很好,我有这个回声php代码,试图从Shoutcast v2 XML中提取“ SONGTITLE”行,但我没有得到,我遇到了一个错误,如果您能检测到我更改了更多行的错误,就会来帮助您我没有实现。 I provide the code: 我提供代码:

 $url = file_get_contents("http://195.201.22.163:8010/stats?sid=1"); $xml = simplexml_load_string($url); foreach ($xml->SONGTITLE as $cancion) $cancion = utf8_decode($cancion); $select = explode(" - ",$cancion); $artista = chop($select[0]); $titulo = chop($select[1]); echo "$artista"; echo "$titulo"; 

I thank you for your help and availability. 多谢您的协助和协助。

You might be getting undefined offset error. 您可能会得到未定义的偏移量错误。 what error is showing at your end? 您的终端显示什么错误? You can use the below code for fixing the offset error. 您可以使用以下代码修复偏移误差。 Also, share more details about what you want to achieve so that I can help you in a better way. 另外,分享有关您要实现的目标的更多详细信息,以便我可以更好地为您提供帮助。

$url = file_get_contents("http://195.201.22.163:8010/stats?sid=1");
$xml = simplexml_load_string($url);
foreach ($xml->SONGTITLE as $cancion){
 $cancion = utf8_decode($cancion);
 $titles = explode(" - ",$cancion); 
  foreach ($titles as $title) {
   echo $title;
  }
 }
 //Output : RCM 96

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM