本帖最后由 xhl122363686 于 2010-11-12 15:05:45 编辑

解决方案 »

  1.   

    $doc = new DOMDocument('1.0','utf-8'); 
    $doc->load($file); //$file表示XML文件的路径  建议将XML与PHP放在同一个文件夹,然后$file直接写XML文件的文件名即可
    $doc->formatOutput = true;
    $Themes = $doc->documentElement->getElementsByTagName('item');//找到所有的item节点
    $Theme = $Themes->item(0);//找到第一个item节点
    $data = $Theme->nodeValue; // 找到该节点的内容。
    以此类推就可以查找出你想要的每一个节点的内容,剩下的我就不多写了。
      

  2.   

    没有一个函数可以把XML文件直接全部解析出来 都得一个个节点去找  如果XML节点格式固定 可以使用循环之内的。
      

  3.   

    这样取得item  就把item里面所有的值取出来了 。。
      

  4.   

    办法很简单将你获取到的array用循环再进行array强制类型转换就ok了!
      

  5.   

    getElementsByTagName("root");
    foreach($root as $roots){
    echo $roots->getElementsByTagName("author")->item(0).nodeValue;
    }
      

  6.   

    我把这个问题提交到bug.php了。。反正暂时我就用3楼的方法解决了。
    php给我回了封信。
    ATTENTION! Do NOT reply to this email!
    To reply, use the web interface found at
    http://bugs.php.net/bug.php?id=53314&edit=2 ID:                 53314
     Updated by:         [email protected]
     Reported by:        122363686 at qq dot com
     Summary:            simplexml_load_string can't parse all tags
    -Status:             Open
    +Status:             Bogus
     Type:               Bug
     Package:            SimpleXML related
     Operating System:   windows XP
     PHP Version:        5.3.3
     Block user comment: N New Comment:Thank you for taking the time to write to us, but this is not
    a bug. Please double-check the documentation available at
    http://www.php.net/manual/ and the instructions on how to report
    a bug at http://bugs.php.net/how-to-report.phpThis is a known detail when printing the SimpleXMLElement using
    print_r(). But the element is there.You can check them using:var_dump($xml->xpath('//textEntryInteraction'));There are others reported related to this, e.g. bug #44973But this is not a PHP bug, thanks.
      

  7.   


    (array)强转后  依旧没有那个标签 之前我试过