0
我想加載一個XML文件,然後評估XML中的2個不同的特定標籤,並將字符串拉入變量..我能夠獲得變量工作,但我無法做到這一點需要兩個變量,因爲事情是被寫在功能..Php解析XML和評估多行設置單獨的變量
這是我加載XML文件...
$test1 = file_get_contents('testfile1.xml');
$dom = new DOMDocument();
@$dom->loadHTML($test1);
這是我評價不同的線..
//line1
$domx1 = new DOMXPath($dom);
$entries1 = $domx1->evaluate("//dominant_period_sec");
$periodArray = array();
foreach ($entries1 as $entry1) {
$wavePeriod = $entry1->nodeValue;
}
//line2
$domx2 = new DOMXPath($dom);
$entries2 = $domx2->evaluate("//dominant_wind_dir");
$avgwaveHeightArray = array();
foreach ($entries2 as $entry2) {
$waveFeet = $entry2->nodeValue;
}