Getting Data from inside a node in XMl with PHP

前端 未结 2 1775
忘了有多久
忘了有多久 2021-01-16 10:44

So im not sure what or how to really describe what i need but hopefully someone will understand.

single element of the total xml file looks like this:

for         


        
2条回答
  •  一向
    一向 (楼主)
    2021-01-16 11:11

    Assuming your Event nodes have one parent (ie ......):

    $xml = simplexml_load_file($file_xml);
    
    foreach($xml->Event as $event) {
        $idAttr = 'ID';
    
        $event_id = (string) $event->attributes()->$idAttr;
        $venue_id = (string) $event->Venue->attributes()->$idAttr;
    
        $venue_img_2 = (string) $event->Venue->Image->Url;
    }
    

提交回复
热议问题