2011-06-28 178 views
0

我有一個XML,我用php simpleXML解析。SimpleXML數據丟失

的XML:

<GetOneGetAll DateTimeSystem="28-06-2011 17:19:29" RetCode="200" RetVal="1" RetMsg="User ok."> 
    <User Id="bc5cb4cf-19a6-4504-8e1a-f72dd97bcc66" ReferedConfirmedUsers="0" TotalRecomendations="0" DistinctRecomendations="0"> 
     <Name>Name</Name> 
     <Surname>Surname</Surname> 
     <Gender>F</Gender> 
     <Email>[email protected]</Email> 
     <RefererCode>59286904</RefererCode> 
     <CustomPhotoMessage HasCustomPhoto="0" HasCustomMessage="0"/> 
     <ReferedConfirmedUsersList/> 
    </User> 
</GetOneGetAll> 

當我print_r的使用SimpleXML我得到了var:

SimpleXMLElement Object 
(
    [@attributes] => Array 
     (
      [DateTimeSystem] => 28-06-2011 17:22:52 
      [RetCode] => 200 
      [RetVal] => 1 
      [RetMsg] => Login ok. 
     ) 

    [User] => SimpleXMLElement Object 
     (
      [@attributes] => Array 
       (
        [Id] => bc5cb4cf-19a6-4504-8e1a-f72dd97bcc66 
        [ReferedConfirmedUsers] => 0 
        [TotalRecomendations] => 0 
        [DistinctRecomendations] => 0 
       ) 

      [Name] => SimpleXMLElement Object 
       (
       ) 

      [Surname] => SimpleXMLElement Object 
       (
       ) 

      [Gender] => SimpleXMLElement Object 
       (
       ) 

      [Email] => SimpleXMLElement Object 
       (
       ) 

      [RefererCode] => SimpleXMLElement Object 
       (
       ) 

      [CustomPhotoMessage] => SimpleXMLElement Object 
       (
        [@attributes] => Array 
         (
          [HasCustomPhoto] => 0 
          [HasCustomMessage] => 0 
         ) 

       ) 

      [ReferedConfirmedUsersList] => SimpleXMLElement Object 
       (
       ) 

     ) 

) 

哪裏的姓,名,電子郵件地址,性別等方面的數據?

+0

它適合我加載。你是通過網頁還是CLI來顯示它?你可以訪問數據而不是print_r它,或者數據不在$ xml_obj-> User-> Surname中嗎? – ben

+0

是的,它好像在那裏,ican訪問它......但不顯示在print_r上。 – AFRC

回答

0

這只是一個猜測,但如果你有安裝xdebug,然後var_dump輸出的默認遞歸級別爲3,此設置xdebug.var_display_max_depth 您正在使用print_r,但一些類似的遞歸限制可以被達到。