Unable to parse XML from PHP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • manjava
    New Member
    • Sep 2009
    • 132

    Unable to parse XML from PHP

    I was not able to find same problem,Ihave Issue below.The Target is to show xml attributes values using soap message.PHP code looks like:
    Code:
     $client = new SoapClient("https://domain.com/xml/listener.asmx?WSDL");
    $Getresults = $client->GetFab(array('Username' => "anyuser", 'Password' => "anypassword", 'code' => "1108324"));
    print_r($Getresults);
    The XML I get from SOAP UI using same request has different structure:
    Code:
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">GetJobResponse xmlns="http://www....>
    <GetJobResult>
                <Number>79593</JobNumber>
                <Status>INVOICED</JobStatus>
                <Code>CB0071</ThirdPartyCode>
    I get Warning: simplexml_load_ string() expects parameter 1 to be string, object given in.?
    Code:
    <pre class='xdebug-var-dump' dir='ltr'>
    <b>object</b>(<i>stdClass</i>)[<i>94</i>]
      <i>public</i> 'JobNumber' <font color='#888a85'>=&gt;</font> <small>int</small> <font color='#4e9a06'>79593</font>
      <i>public</i> 'JobStatus' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'INVOICED'</font> <i>(length=8)</i>
      <i>public</i> 'ThirdPartyCode' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'CB0071'</font> <i>(length=6)</i>
      <i>public</i> 'CustomerName' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'BECK CRESPEL'</font> <i>(length=12)</i>
      <i>public</i> 'CustomerName_' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>''</font> <i>(length=0)</i>
      <i>public</i> 'Reference' <font color='#888a85'>=&gt;</font> <small>int</small> <font color='#4e9a06'>1169910</font>
      <i>public</i> 'ContactSeq' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'106798'</font> <i>(length=6)</i>
      <i>public</i> 'Date' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'2015-04-08T00:00:00'</font> <i>(length=19)</i>
      <i>public</i> 'DateCompleted' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'0001-01-01T00:00:00'</font> <i>(length=19)</i>
      <i>public</i> 'Title' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'E : LIVRET D ACCUEIL - WIREO - 70 PAGES (35 FEUILLETS) - 21 X 14.8 CM - Q RV'</font> <i>(length=76)</i>
      <i>public</i> 'Quantity' <font color='#888a85'>=&gt;</font> <small>int</small> <font color='#4e9a06'>200</font>
      <i>public</i> 'Product' <font color='#888a85'>=&gt;</font>
    Thanks for you help
    Last edited by Dormilich; Jun 5 '15, 10:06 AM. Reason: topic php
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    your soap call does not return you an XML but an already parsed result object. SOAP would be quite pointless if you had to parse the XML each time yourself.

    Comment

    • manjava
      New Member
      • Sep 2009
      • 132

      #3
      Thanks how can i resolve this issue

      Thanks in advance

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        just use the object you get. it holds the same information as the XML.

        Comment

        • manjava
          New Member
          • Sep 2009
          • 132

          #5
          i don't know how can i do with simple xml i do that
          Code:
          $xml=simple_load_string($GetJobresult);
          i have this warning simple_load_str ing() expects parameter 1 to be string ,object given

          Thanks for you help

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            scrap that line, you don’t need it.

            Comment

            • manjava
              New Member
              • Sep 2009
              • 132

              #7
              so please can you tell by code what i put because i need parse with simple xml

              Thanks in advance

              Comment

              • Dormilich
                Recognized Expert Expert
                • Aug 2008
                • 8694

                #8
                i need parse with simple xml
                no you don’t.

                Comment

                • manjava
                  New Member
                  • Sep 2009
                  • 132

                  #9
                  i am not understand please can you tell me what can i do so if possible by code script

                  Thanks in advance

                  Comment

                  • Dormilich
                    Recognized Expert Expert
                    • Aug 2008
                    • 8694

                    #10
                    here’s the code:
                    Code:
                    $Getresults = $client->GetFab(array('Username' => "anyuser", 'Password' => "anypassword", 'code' => "1108324"));
                    
                    $JobNumber = $Getresults->JobNumber;

                    Comment

                    • manjava
                      New Member
                      • Sep 2009
                      • 132

                      #11
                      for example i have that also on $Getresults
                      Code:
                      object(stdClass)[101]
                            public 'any' => string '<GROUPS xmlns=""><GROUP seq="342"><FIN seq="422"><VAL>1</VAL><ATT seq="732"><LINE>0</LINE><VAL/></ATT><ATT seq="726"><VAL>200</VAL></ATT><ATT seq="426"><VAL>35</VAL></ATT><ATT seq="423"><LINE>0</LINE><VAL>1</VAL></ATT><ATT seq="733"><LINE>0</LINE><VAL/></ATT><ATT seq="727"><VAL>0</VAL></ATT><ATT seq="731"><VAL>0</VAL></ATT><ATT seq="728"><LINE>0</LINE><VAL>3</VAL></ATT><ATT seq="2534"><LINE>0</LINE><VAL/></ATT><ATT seq="8967"><LINE>1</LINE><VAL>1</VAL></ATT><TEXT>Reliure wire'o  200 exemplaires  de 35 feuil'... (length=6349)
                        public 'Components' => 
                          object(stdClass)[105]
                            public 'Component' => 
                              array (size=3)
                                0 => 
                                  object(stdClass)[104]
                                    ...
                                1 => 
                                  object(stdClass)[113]
                      how can i do to get :GlobtechData->GROUPS->GROUP->GROUP seq=290@REM
                      Thanks in advance

                      Comment

                      • Dormilich
                        Recognized Expert Expert
                        • Aug 2008
                        • 8694

                        #12
                        Code:
                        simplexml_load_string($Getresults->any);

                        Comment

                        • manjava
                          New Member
                          • Sep 2009
                          • 132

                          #13
                          i write
                          Code:
                          $xml=simplexml_load_string($Getresults->any);
                          Have this error Notice:Undefine d property :stdClass::$any in c:\wamp\www\cla sstest.php

                          Thanks in advance

                          Comment

                          • Dormilich
                            Recognized Expert Expert
                            • Aug 2008
                            • 8694

                            #14
                            doesn’t make sense with the code you have given. unless the output above was a subresult of the response.

                            best you check var_dump($Getre sults); for the property you want.

                            Comment

                            • manjava
                              New Member
                              • Sep 2009
                              • 132

                              #15
                              var_dump($Getre sults);
                              Code:
                              object(stdClass)[94]
                                public 'JobNumber' => int 79593
                                public 'JobStatus' => string 'INVOICED' (length=8)
                                public 'ThirdPartyCode' => string 'CB0071' (length=6)
                                public 'CustomerName' => string 'BECK CRESPEL' (length=12)
                                public 'CustomerName_' => string '' (length=0)
                                public 'Reference' => int 1169910
                                public 'ContactSeq' => string '106798' (length=6)
                                public 'Date' => string '2015-04-08T00:00:00' (length=19)
                                public 'DateCompleted' => string '0001-01-01T00:00:00' (length=19)
                                public 'Title' => string 'E : LIVRET D ACCUEIL - WIREO - 70 PAGES (35 FEUILLETS) - 21 X 14.8 CM - Q RV' (length=76)
                                public 'Quantity' => int 200
                                public 'Product' => string 'BRW' (length=3)
                                public 'Units' => int 0
                                public 'Price' => float 923
                                public 'ThousandP' => float 3587
                                public 'EstimatePrice' => float 923
                                public 'Currency' => string 'EUR' (length=3)
                                public 'Operator' => string 'HC' (length=2)
                                public 'SalesRepresentativeCode' => string '06' (length=2)
                                public 'SalesRepresentativeName' => string 'PASCAL DEROLEZ' (length=14)
                                public 'StatusTitle' => string '' (length=0)
                                public 'ExpectedShippingDate' => string '2015-04-17T00:00:00' (length=19)
                                public 'ThirdPartyRef' => string 'E : LIVRET D ACCUEIL - WIREO - 70 PAGES (35 FEUILLETS) - 21 X 14.8 CM - Q RV' (length=76)
                                public 'Gangrun' => boolean false
                                public 'EstimateNumber' => int 86345
                                public 'EstimateVariantNumber' => int 1
                                public 'ConfirmationLetterBody' => string '
                              LIVRET D ACCUEIL - WIREO - 70 PAGES (35 FEUILLETS) - 21 X 14.8 CM - Q RV
                              
                              Format               rogné  21 x  14.8 cm
                              Contenu              dessus dessous
                                                   Intérieur 33 feuillets
                              Prépresse            Fichier PDF fourni avec intervention
                                                   Fichier à composer ou à modifier suivant vos éléments : 
                                                   Mise en page -   
                                                   Epreuve de contrôle électronique
                              Impression           dessus dessous quadri au recto / quadri au verso
                                     '... (length=1185)
                                public 'CustomInfo' => 
                                  object(stdClass)[103]
                                    public 'FromCaux' => boolean false
                                    public 'Name' => string 'BECK CRESPEL' (length=12)
                                    public 'Name_' => string '' (length=0)
                                    public 'Address' => string '40 Rue des Fusilles' (length=19)
                                    public 'Address_' => string '' (length=0)
                                    public 'Zip' => string '59427' (length=5)
                                    public 'City' => string 'ARMENTIERES CEDEX' (length=17)
                                    public 'Country' => string 'FRANCE' (length=6)
                                    public 'Tel' => string '03 20 77 78 88' (length=14)
                                    public 'Fax' => string '03 20 77 82 01' (length=14)
                                    public 'RepCode' => string '06' (length=2)
                                    public 'ThirdPartyRef' => string 'E : LIVRET D ACCUEIL - WIREO - 70 PAGES (35 FEUILLETS) - 21 X 14.8 CM - Q RV' (length=76)
                                    public 'PaymentMethod' => string 'ON_RECEIPT_OF_INVOICE' (length=21)
                                    public 'PaymentMode' => string 'CHEQUE' (length=6)
                                    public 'Expiry' => int 1
                                    public 'PayDate' => int 30
                                    public 'Discount' => float 0
                                    public 'CustToInvoice' => string '' (length=0)
                                public 'JobInfo' => 
                                  object(stdClass)[102]
                                    public 'Notes' => string '' (length=0)
                                    public 'BindingTxt' => string 'Encart : : 
                              
                              Encart : : 
                              
                              Assemblage 
                              
                              ' (length=39)
                                    public 'PackingTxt' => string '8 Mise sous film (3.348 ) de 25 exemplaires  (.134 )  en
                                   2 Cartons A4 (13.39 ) de 4 Mise sous film (Premier sous devis)
                              ' (length=125)
                                    public 'DeliveryTxt' => string '' (length=0)
                                    public 'PrePressInfos' => 
                                      object(stdClass)[100]
                                public 'GlobTechData' => 
                                  object(stdClass)[101]
                                    public 'any' => string '<GROUPS xmlns=""><GROUP seq="342"><FIN seq="422"><VAL>1</VAL><ATT seq="732"><LINE>0</LINE><VAL/></ATT><ATT seq="726"><VAL>200</VAL></ATT><ATT seq="426"><VAL>35</VAL></ATT><ATT seq="423"><LINE>0</LINE><VAL>1</VAL></ATT><ATT seq="733"><LINE>0</LINE><VAL/></ATT><ATT seq="727"><VAL>0</VAL></ATT><ATT seq="731"><VAL>0</VAL></ATT><ATT seq="728"><LINE>0</LINE><VAL>3</VAL></ATT><ATT seq="2534"><LINE>0</LINE><VAL/></ATT><ATT seq="8967"><LINE>1</LINE><VAL>1</VAL></ATT><TEXT>Reliure wire'o  200 exemplaires  de 35 feuil'... (length=6349)
                                public 'Components' => 
                                  object(stdClass)[105]
                                    public 'Component' => 
                                      array (size=3)
                                        0 => 
                                          object(stdClass)[104]
                                            ...
                                        1 => 
                                          object(stdClass)[113]
                                            ...
                                        2 => 
                                          object(stdClass)[121]
                                            ...
                                public 'JobParts' => 
                                  object(stdClass)[129]
                                    public 'JobPart' => 
                                      object(stdClass)[130]
                                        public 'Title' => string 'Premier sous devis' (length=18)
                                        public 'CustomRef' => string '' (length=0)
                                        public 'Quantity' => int 200
                                        public 'ElemNo' => 
                                          object(stdClass)[131]
                                            ...
                                public 'DeliveryInfos' => 
                                  object(stdClass)[132]
                                    public 'DeliveryInfo' => 
                                      object(stdClass)[133]
                                        public 'Number' => int 70565
                                        public 'AdrRef' => int 0
                                        public 'ExpectedQuantity' => int 200
                                        public 'DeliveredQuantity' => int 200
                                        public 'Price' => float 0
                                        public 'CostAmount' => float 0
                                        public 'Name' => string 'BECK CRESPEL' (length=12)
                                        public 'Name_' => string '' (length=0)
                                        public 'Comment' => string '' (length=0)
                                        public 'TransportType' => string '' (length=0)
                                        public 'Address' => string '40 Rue des Fusilles' (length=19)
                                        public 'Address_' => string '' (length=0)
                                        public 'Zip' => string '59427' (length=5)
                                        public 'City' => string 'ARMENTIERES CEDEX' (length=17)
                                        public 'Province' => null
                                        public 'ProvinceName' => string '' (length=0)
                                        public 'Country' => string 'FRANCE' (length=6)
                                        public 'Tel' => string '03 20 77 78 88' (length=14)
                                        public 'Contact' => string 'URBANSKI Nadine' (length=15)
                                        public 'Language' => string 'F' (length=1)
                                        public 'JobNumber' => int 79593
                                        public 'ThirdPartyCode' => string 'CB0071' (length=6)
                                        public 'Order' => int 1
                                        public 'DeliveryDate' => string '2015-05-19T06:29:00' (length=19)
                                        public 'ExpectedDate' => string '2015-04-17T00:00:00' (length=19)
                                        public 'Company' => string '001' (length=3)
                                        public 'Establishment' => string '001' (length=3)
                                        public 'Seq' => int 968652
                                        public 'TrackingNumber' => string '' (length=0)
                                        public 'Text' => string '
                              LIVRET D ACCUEIL - WIREO - 70 PAGES (35 FEUILLETS) - 21 X 14.8 CM - Q RV
                              
                              Format               rogné  21 x  14.8 cm
                              Contenu              dessus dessous
                                                   Intérieur 33 feuillets
                              Prépresse            Fichier PDF fourni avec intervention
                                                   Fichier à composer ou à modifier suivant vos éléments : 
                                                   Mise en page -   
                                                   Epreuve de contrôle électronique
                              Impression           dessus dessous quadri au recto / quadri au verso
                                     '... (length=1202)
                                        public 'ShippingCompanySeq' => int 0
                                        public 'DeliveryInfo1' => string '' (length=0)
                                        public 'DeliveryInfo2' => string '' (length=0)
                                        public 'DeliveryInfo3' => string '' (length=0)
                                        public 'DeliveryInfo4' => string '' (length=0)
                                public 'ScheduleInfos' => 
                                  object(stdClass)[134]
                                    public 'ScheduleInfo' => 
                                      array (size=14)
                                        0 => 
                                          object(stdClass)[135]
                                            ...
                                        1 => 
                                          object(stdClass)[136]
                                            ...
                                        2 => 
                                          object(stdClass)[137]
                                            ...
                                        3 => 
                                          object(stdClass)[138]
                                            ...
                                        4 => 
                                          object(stdClass)[139]
                                            ...
                                        5 => 
                                          object(stdClass)[140]
                                            ...
                                        6 => 
                                          object(stdClass)[141]
                                            ...
                                        7 => 
                                          object(stdClass)[142]
                                            ...
                                        8 => 
                                          object(stdClass)[143]
                                            ...
                                        9 => 
                                          object(stdClass)[144]
                                            ...
                                        10 => 
                                          object(stdClass)[145]
                                            ...
                                        11 => 
                                          object(stdClass)[146]
                                            ...
                                        12 => 
                                          object(stdClass)[147]
                                            ...
                                        13 => 
                                          object(stdClass)[148]
                                            ...
                                public 'JobReferences' => 
                                  object(stdClass)[149]
                                    public 'JobReference' => 
                                      array (size=7)
                                        0 => 
                                          object(stdClass)[150]
                                            ...
                                        1 => 
                                          object(stdClass)[151]
                                            ...
                                        2 => 
                                          object(stdClass)[152]
                                            ...
                                        3 => 
                                          object(stdClass)[153]
                                            ...
                                        4 => 
                                          object(stdClass)[154]
                                            ...
                                        5 => 
                                          object(stdClass)[155]
                                            ...
                                        6 => 
                                          object(stdClass)[156]
                                            ...
                                public 'JobSeq' => int 920179
                                public 'Establishment' => string '001' (length=3)
                                public 'Company' => string '001' (length=3)

                              Comment

                              Working...