0
我對XML沒什麼問題。我的XML文件是這個樣子:使用PHP解析XML
http://pastebin.com/MQUB2W2B我的用戶,因爲引擎收錄本網站不支持XML代碼..://
,所以我需要選擇源支架「/流」等源安裝「/」。我的PHP代碼如下所示:
Class stream {
Public Function __construct($host, $path, $user, $pass, $mpoint){
$this->host = $host;
$this->path = $path;
$this->user = $user;
$this->password = $pass;
$this->mpoint = $mpoint;
$this->url = "http://{$this->user}:{$this->password}@{$this->host}/{$this->path}";
$this->xml = simplexml_load_file($this->url);
}
Public Function audio($url, $format){
return print "<audio controls> <source src=\"{$url}\" type=\"audio/{$format}\"> </audio>";
}
Public Function stream_meta(){
$xml = $this->xml->registerXPathNamespace('test', '/{$this->mpoint}');
$result = $xml->xpath('test:artist');
return $result;
}
Public Function nowplay(){
return $this->xml->source[0]->artist;
}
Public Function download($format){
$link = "http://{$this->host}/{$this->mpoint}";
if($format == "m3u"){
return "{$link}.m3u";
}
elseif($format == "xspf"){
return "{$link}.xspf";
}
elseif($format == "vclt"){
return "{$link}.vclt";
}
return false;
}
}
所以現在我問我做錯了什麼或者我能做得更好?我需要選擇藝術家數據並且知道什麼是源碼「」這是什麼?「。我真的需要幫助。我不知道我能做什麼,我不發明其他方式來做到這一點。我很累,我真的需要幫助!請幫助我嗎?我不想使用「nowplay()」功能。因爲源安裝「/ example」更改有時...
Thanks!但我怎麼才能得到
非常感謝!我必須去測試這個! – T0niiiiii
就像只有一個藝術家的'source',或者'mount =「/ stream」'的藝術家一樣? –