simplexml这个队中文的支持不大好用阿Warning: simplexml_load_file() [function.simplexml-load-file]: /home/www/.../home/.../Tmp/xxx.txt:1: parser error : Extra content at the end of the document in /home/www/.../home/.../parsexml.class.php on line 64Warning: simplexml_load_file() [function.simplexml-load-file]: <name>袁莹</name><place>董事总经理</place><company>广州市蓝色火焰广告有限公司</c in /home/www/.../home/.../parsexml.class.php on line 64Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in /home/www/.../home/.../parsexml.class.php on line 64Fatal error: Call to a member function children() on a non-object in /home/www/.../home/.../parsexml.class.php on line 71

解决方案 »

  1.   

    中文必须是utf-8格式的.
    建议可以用
    $strXML = file_get_contents("/home/www/.../home/.../Tmp/xxx.txt");
    $so = simplexml_load_string(iconv('gbk','utf-8',$strXML));
      

  2.   

    还是不能。悲剧了文件保存成utf-8的也是不行 $p = xml_parser_create('utf-8');
    xml_parse_into_struct($p, file_get_contents($this->tmpdir . $_FILES['xmlfile']['name']), $vals, $index);
    xml_parser_free($p);
    print_r($vals);
      

  3.   


    数据是这样的:
    <name>周志泉</name><place>媒介策划经理</place><company>广州市蓝色火焰广告有限公司</company><email>[email protected]</email>
    <name>辛晓东</name><place>媒介专项组副总监</place><company>广州市蓝色火焰广告有限公司</company><email>[email protected]</email>只能读出第一个Array ( [0] => Array ( [tag] => NAME [type] => complete [level] => 1 [value] => 周志泉 ) ) 这个是怎么的?
      

  4.   

    $xml = <<< XML
    <root>
    <name>周志泉 </name> <place>媒介策划经理 </place> <company>广州市蓝色火焰广告有限公司 </company> <email>[email protected] </email> 
    <name>辛晓东 </name> <place>媒介专项组副总监 </place> <company>广州市蓝色火焰广告有限公司 </company> <email>[email protected] </email>
    </root>
    XML;$dom = simplexml_load_string(iconv('gbk', 'utf-8', $xml));
    print_r($dom);SimpleXMLElement Object
    (
        [name] => Array
            (
                [0] => 周志泉 
                [1] => 辛晓东 
            )    [place] => Array
            (
                [0] => 媒介策划经理 
                [1] => 媒介专项组副总监 
            )    [company] => Array
            (
                [0] => 广州市蓝色火焰广告有限公司 
                [1] => 广州市蓝色火焰广告有限公司 
            )    [email] => Array
            (
                [0] => [email protected] 
                [1] => [email protected] 
            ))