解析xml文件

function sxe($url)
    {   
        $xml = file_get_contents($url);
        foreach ($http_response_header as $header)
        {   
            if (preg_match('#^Content-Type: text/xml; charset=(.*)#i', $header, $m))
            {   
                switch (strtolower($m[1]))
                {   
                    case 'utf-8':
                        // do nothing
                        break;

                    case 'iso-8859-1':
                        $xml = utf8_encode($xml);
                        break;

                    default:
                        $xml = iconv($m[1], 'utf-8', $xml);
                }
                break;
            }
        }

        return simplexml_load_string($xml);
    }
时不我待,不负韶华!立刻行动!不吃学习的苦就会吃生活的苦!
原文地址:https://www.cnblogs.com/zrp2013/p/3418357.html