2014-06-05 63 views
0

我不是很擅長php/XML我得到這個使用谷歌等遠,但不能進一步。 我用加載不同的xml文件到一個數組在php中

<?php 
    $counter=0; 
foreach($proxml->test->children() as $test1) { 
    $counter++; 
    $name=$test1->Name ; 
    $test[$counter]="http://url".$name."/test?xml=1" ; 
    } 
$xml=simplexml_load_file("$test[1]"); 
$xml1=simplexml_load_file("$test[2]"); 
$xml2=simplexml_load_file("$test[3]"); 
$xml3=simplexml_load_file("$test[4]"); 
$xml4=simplexml_load_file("$test[5]"); 
$xmls = array($xml, $xml1, $xml2, $xml3, $xml4); 
echo $xmls ; 
?> 

每個測試是具有類似UNIX時間戳XML信息不同的URL。

我想把所有的XML文件放到一個數組中,然後提取所有的<時間戳>並對其進行排序。然後輸出它與屬於時間戳的其他信息,如<名稱>等。

它適用於1個URL,但無法讓它工作以將URL相乘。

+0

這有什麼錯運行'的foreach($測試爲$ URL){$ XML =使用simplexml_load_file($網址);}'? –

+0

我用1個XML文件$ proxml得到的名稱和這個名字我作出新的網址,然後將它們也是XML。每個XML只是不同的名稱。所以我想從中排序並顯示它。 – Johanson

+0

在下面看到我的帖子。 –

回答

0

試試這個:

<?php 
$counter=0; 
foreach($proxml->test->children() as $test1) { 
    $counter++; 
    $name=$test1->Name ; 
    $test[ $counter ] = "http://url" . $name . "/test?xml=1"; 
} 

foreach($test as $url) { 
    $xml = simplexml_load_file($url); 
     // will display the xml, you can read it and get required values 
    echo $xml->asXML(); 
} 
?> 
+0

顯示之類的公共3 65.4 1399400601 1399442265.但我只想來顯示時間戳記,但我如何使用它。顯示與時間戳相關的其他信息? – Johanson

+0

你能分享一個xml的截圖嗎? –

+0

http://puu.sh/9g4xS/e89f74e2af.png這裏是它的一部分的屏幕截圖。這是$ test xml的 – Johanson

相關問題