PHP Retrieve DATA from XML

后端 未结 4 469
盖世英雄少女心
盖世英雄少女心 2021-01-24 06:13

My first attempt at retrieving data from XML for a maps application has failed. Here is a piece of the XML Feed.

         


        
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-24 06:28

    function XMLReader()
    {
        $MyArray = array();
    
        $doc = new DOMDocument(); 
        $doc->load( 'XMLFilePath.xml' ); 
        $info = $doc->getElementsByTagName( "leg" );
        foreach( $info as $Type )
        {
            $details = $Type->getElementsByTagName( "start_address" );
            $detail = $details->item(0)->nodeValue;     
            $MyArray [] = $detail; 
        }
    
        return $MyArray;
    }
    

    and same for end_Address. I wish this answer is helpful.

提交回复
热议问题