XML parsing conundrum

后端 未结 7 1411
甜味超标
甜味超标 2021-01-15 22:25

UPDATE: I\'ve reworked the question, to show progress I\'ve made, and maybe make it easier to answer.

UPDATE 2: I\'ve added another value to the XML. Extension avail

7条回答
  •  野的像风
    2021-01-15 22:53

    You can try this:

    $scrape_xml = "files.xml";
    $xml = simplexml_load_file($scrape_xml);
    
    $group = array();
    
    foreach ($xml->Item as $file)
    {
        $platform = stripslashes($file->Platform);
        $name = stripslashes($file->Name);
        $title = stripslashes($file->Title);
        $downloadPath = stripslashes($file->DownloadPath);
    
        if(!isset($group[$platform]))
        {
            $group[$platform] = array();
            $group[$platform][] = array("Name" => $name,"Title" => $title, "Files" => array($downloadPath));
        }
        else
        {
            $found = false;
    
            for($i=0;$i $name,"Title" => $title, "Files" => array($downloadPath));
            }
        }
    }
    
    echo "
    ".print_r($group,true)."
    ";

提交回复
热议问题