doubaisui2526 2015-06-16 14:43
浏览 286

警告:simplexml_load_string()期望参数1为str​​ing,给定数组

I have this error :Warning: simplexml_load_string() expects parameter 1 to be string, object given in on line 195

and also this error: Fatal error: Call to a member function xpath() on a non-object in C:\wamp\

so my code in following :

foreach ( $GetJobResult->JobReferences as $jobreference_index => $JobReferences ) {
            if (isset ( $GetJobResult->JobReferences )) {

                $xmlJobReference = simplexml_load_string ( $JobReferences );

                $JobReferencetitle = $xmlJobReference->xpath ( "//JobReference[Title ='N°  ANCIEN DOSSIER']/Reference" );


                var_dump($GetJobResult->JobReferences);

            }
        }

var_dump($GetJobResult->JobReferences);

object(stdClass)[149]
  public 'JobReference' => 
    array (size=7)
      0 => 
        object(stdClass)[150]
          public 'Type' => string 'STANDARD' (length=8)
          public 'Title' => string 'N° cde client' (length=14)
          public 'Reference' => string '' (length=0)
          public 'ValueType' => string 'ALPHANUMERIC' (length=12)
          public 'ValueLength_Minimum' => int 0
          public 'ValueLength_Maximum' => int 20
      1 => 
        object(stdClass)[151]
          public 'Type' => string 'STANDARD' (length=8)
          public 'Title' => string 'N°  ANCIEN DOSSIER' (length=19)
          public 'Reference' => string '' (length=0)
          public 'ValueType' => string 'NUMERIC' (length=7)
          public 'ValueLength_Minimum' => int 0
          public 'ValueLength_Maximum' => int 6
  • 写回答

2条回答 默认 最新

  • doucaigai7176 2015-06-16 15:00
    关注

    simplexml_load_string transforms string to SimpleXmlElement. You are passing object. Thats the problem.

    评论

报告相同问题?