473,513 Members | 4,753 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unable to parse XML from PHP

132 New Member
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:
Expand|Select|Wrap|Line Numbers
  1.  $client = new SoapClient("https://domain.com/xml/listener.asmx?WSDL");
  2. $Getresults = $client->GetFab(array('Username' => "anyuser", 'Password' => "anypassword", 'code' => "1108324"));
  3. print_r($Getresults);
The XML I get from SOAP UI using same request has different structure:
Expand|Select|Wrap|Line Numbers
  1. <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....>
  2. <GetJobResult>
  3.             <Number>79593</JobNumber>
  4.             <Status>INVOICED</JobStatus>
  5.             <Code>CB0071</ThirdPartyCode>
I get Warning: simplexml_load_string() expects parameter 1 to be string, object given in.?
Expand|Select|Wrap|Line Numbers
  1. <pre class='xdebug-var-dump' dir='ltr'>
  2. <b>object</b>(<i>stdClass</i>)[<i>94</i>]
  3.   <i>public</i> 'JobNumber' <font color='#888a85'>=&gt;</font> <small>int</small> <font color='#4e9a06'>79593</font>
  4.   <i>public</i> 'JobStatus' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'INVOICED'</font> <i>(length=8)</i>
  5.   <i>public</i> 'ThirdPartyCode' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'CB0071'</font> <i>(length=6)</i>
  6.   <i>public</i> 'CustomerName' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'BECK CRESPEL'</font> <i>(length=12)</i>
  7.   <i>public</i> 'CustomerName_' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>''</font> <i>(length=0)</i>
  8.   <i>public</i> 'Reference' <font color='#888a85'>=&gt;</font> <small>int</small> <font color='#4e9a06'>1169910</font>
  9.   <i>public</i> 'ContactSeq' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'106798'</font> <i>(length=6)</i>
  10.   <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>
  11.   <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>
  12.   <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>
  13.   <i>public</i> 'Quantity' <font color='#888a85'>=&gt;</font> <small>int</small> <font color='#4e9a06'>200</font>
  14.   <i>public</i> 'Product' <font color='#888a85'>=&gt;</font> 
Thanks for you help
Jun 4 '15 #1
26 2537
Dormilich
8,658 Recognized Expert Moderator Expert
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.
Jun 5 '15 #2
manjava
132 New Member
Thanks how can i resolve this issue

Thanks in advance
Jun 5 '15 #3
Dormilich
8,658 Recognized Expert Moderator Expert
just use the object you get. it holds the same information as the XML.
Jun 5 '15 #4
manjava
132 New Member
i don't know how can i do with simple xml i do that
Expand|Select|Wrap|Line Numbers
  1. $xml=simple_load_string($GetJobresult);
i have this warning simple_load_string() expects parameter 1 to be string ,object given

Thanks for you help
Jun 5 '15 #5
Dormilich
8,658 Recognized Expert Moderator Expert
scrap that line, you don’t need it.
Jun 5 '15 #6
manjava
132 New Member
so please can you tell by code what i put because i need parse with simple xml

Thanks in advance
Jun 5 '15 #7
Dormilich
8,658 Recognized Expert Moderator Expert
i need parse with simple xml
no you don’t.
Jun 5 '15 #8
manjava
132 New Member
i am not understand please can you tell me what can i do so if possible by code script

Thanks in advance
Jun 5 '15 #9
Dormilich
8,658 Recognized Expert Moderator Expert
here’s the code:
Expand|Select|Wrap|Line Numbers
  1. $Getresults = $client->GetFab(array('Username' => "anyuser", 'Password' => "anypassword", 'code' => "1108324"));
  2.  
  3. $JobNumber = $Getresults->JobNumber;
  4.  
Jun 5 '15 #10
manjava
132 New Member
for example i have that also on $Getresults
Expand|Select|Wrap|Line Numbers
  1. object(stdClass)[101]
  2.       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)
  3.   public 'Components' => 
  4.     object(stdClass)[105]
  5.       public 'Component' => 
  6.         array (size=3)
  7.           0 => 
  8.             object(stdClass)[104]
  9.               ...
  10.           1 => 
  11.             object(stdClass)[113]
how can i do to get :GlobtechData->GROUPS->GROUP->GROUP seq=290@REM
Thanks in advance
Jun 5 '15 #11
Dormilich
8,658 Recognized Expert Moderator Expert
Expand|Select|Wrap|Line Numbers
  1. simplexml_load_string($Getresults->any);
Jun 5 '15 #12
manjava
132 New Member
i write
Expand|Select|Wrap|Line Numbers
  1. $xml=simplexml_load_string($Getresults->any);
Have this error Notice:Undefined property :stdClass::$any in c:\wamp\www\classtest.php

Thanks in advance
Jun 5 '15 #13
Dormilich
8,658 Recognized Expert Moderator Expert
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($Getresults); for the property you want.
Jun 5 '15 #14
manjava
132 New Member
var_dump($Getresults);
Expand|Select|Wrap|Line Numbers
  1. object(stdClass)[94]
  2.   public 'JobNumber' => int 79593
  3.   public 'JobStatus' => string 'INVOICED' (length=8)
  4.   public 'ThirdPartyCode' => string 'CB0071' (length=6)
  5.   public 'CustomerName' => string 'BECK CRESPEL' (length=12)
  6.   public 'CustomerName_' => string '' (length=0)
  7.   public 'Reference' => int 1169910
  8.   public 'ContactSeq' => string '106798' (length=6)
  9.   public 'Date' => string '2015-04-08T00:00:00' (length=19)
  10.   public 'DateCompleted' => string '0001-01-01T00:00:00' (length=19)
  11.   public 'Title' => string 'E : LIVRET D ACCUEIL - WIREO - 70 PAGES (35 FEUILLETS) - 21 X 14.8 CM - Q RV' (length=76)
  12.   public 'Quantity' => int 200
  13.   public 'Product' => string 'BRW' (length=3)
  14.   public 'Units' => int 0
  15.   public 'Price' => float 923
  16.   public 'ThousandP' => float 3587
  17.   public 'EstimatePrice' => float 923
  18.   public 'Currency' => string 'EUR' (length=3)
  19.   public 'Operator' => string 'HC' (length=2)
  20.   public 'SalesRepresentativeCode' => string '06' (length=2)
  21.   public 'SalesRepresentativeName' => string 'PASCAL DEROLEZ' (length=14)
  22.   public 'StatusTitle' => string '' (length=0)
  23.   public 'ExpectedShippingDate' => string '2015-04-17T00:00:00' (length=19)
  24.   public 'ThirdPartyRef' => string 'E : LIVRET D ACCUEIL - WIREO - 70 PAGES (35 FEUILLETS) - 21 X 14.8 CM - Q RV' (length=76)
  25.   public 'Gangrun' => boolean false
  26.   public 'EstimateNumber' => int 86345
  27.   public 'EstimateVariantNumber' => int 1
  28.   public 'ConfirmationLetterBody' => string '
  29. LIVRET D ACCUEIL - WIREO - 70 PAGES (35 FEUILLETS) - 21 X 14.8 CM - Q RV
  30.  
  31. Format               rogné  21 x  14.8 cm
  32. Contenu              dessus dessous
  33.                      Intérieur 33 feuillets
  34. Prépresse            Fichier PDF fourni avec intervention
  35.                      Fichier Ã  composer ou Ã  modifier suivant vos Ã©léments : 
  36.                      Mise en page -   
  37.                      Epreuve de contrôle Ã©lectronique
  38. Impression           dessus dessous quadri au recto / quadri au verso
  39.        '... (length=1185)
  40.   public 'CustomInfo' => 
  41.     object(stdClass)[103]
  42.       public 'FromCaux' => boolean false
  43.       public 'Name' => string 'BECK CRESPEL' (length=12)
  44.       public 'Name_' => string '' (length=0)
  45.       public 'Address' => string '40 Rue des Fusilles' (length=19)
  46.       public 'Address_' => string '' (length=0)
  47.       public 'Zip' => string '59427' (length=5)
  48.       public 'City' => string 'ARMENTIERES CEDEX' (length=17)
  49.       public 'Country' => string 'FRANCE' (length=6)
  50.       public 'Tel' => string '03 20 77 78 88' (length=14)
  51.       public 'Fax' => string '03 20 77 82 01' (length=14)
  52.       public 'RepCode' => string '06' (length=2)
  53.       public 'ThirdPartyRef' => string 'E : LIVRET D ACCUEIL - WIREO - 70 PAGES (35 FEUILLETS) - 21 X 14.8 CM - Q RV' (length=76)
  54.       public 'PaymentMethod' => string 'ON_RECEIPT_OF_INVOICE' (length=21)
  55.       public 'PaymentMode' => string 'CHEQUE' (length=6)
  56.       public 'Expiry' => int 1
  57.       public 'PayDate' => int 30
  58.       public 'Discount' => float 0
  59.       public 'CustToInvoice' => string '' (length=0)
  60.   public 'JobInfo' => 
  61.     object(stdClass)[102]
  62.       public 'Notes' => string '' (length=0)
  63.       public 'BindingTxt' => string 'Encart : : 
  64.  
  65. Encart : : 
  66.  
  67. Assemblage 
  68.  
  69. ' (length=39)
  70.       public 'PackingTxt' => string '8 Mise sous film (3.348 ) de 25 exemplaires  (.134 )  en
  71.      2 Cartons A4 (13.39 ) de 4 Mise sous film (Premier sous devis)
  72. ' (length=125)
  73.       public 'DeliveryTxt' => string '' (length=0)
  74.       public 'PrePressInfos' => 
  75.         object(stdClass)[100]
  76.   public 'GlobTechData' => 
  77.     object(stdClass)[101]
  78.       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)
  79.   public 'Components' => 
  80.     object(stdClass)[105]
  81.       public 'Component' => 
  82.         array (size=3)
  83.           0 => 
  84.             object(stdClass)[104]
  85.               ...
  86.           1 => 
  87.             object(stdClass)[113]
  88.               ...
  89.           2 => 
  90.             object(stdClass)[121]
  91.               ...
  92.   public 'JobParts' => 
  93.     object(stdClass)[129]
  94.       public 'JobPart' => 
  95.         object(stdClass)[130]
  96.           public 'Title' => string 'Premier sous devis' (length=18)
  97.           public 'CustomRef' => string '' (length=0)
  98.           public 'Quantity' => int 200
  99.           public 'ElemNo' => 
  100.             object(stdClass)[131]
  101.               ...
  102.   public 'DeliveryInfos' => 
  103.     object(stdClass)[132]
  104.       public 'DeliveryInfo' => 
  105.         object(stdClass)[133]
  106.           public 'Number' => int 70565
  107.           public 'AdrRef' => int 0
  108.           public 'ExpectedQuantity' => int 200
  109.           public 'DeliveredQuantity' => int 200
  110.           public 'Price' => float 0
  111.           public 'CostAmount' => float 0
  112.           public 'Name' => string 'BECK CRESPEL' (length=12)
  113.           public 'Name_' => string '' (length=0)
  114.           public 'Comment' => string '' (length=0)
  115.           public 'TransportType' => string '' (length=0)
  116.           public 'Address' => string '40 Rue des Fusilles' (length=19)
  117.           public 'Address_' => string '' (length=0)
  118.           public 'Zip' => string '59427' (length=5)
  119.           public 'City' => string 'ARMENTIERES CEDEX' (length=17)
  120.           public 'Province' => null
  121.           public 'ProvinceName' => string '' (length=0)
  122.           public 'Country' => string 'FRANCE' (length=6)
  123.           public 'Tel' => string '03 20 77 78 88' (length=14)
  124.           public 'Contact' => string 'URBANSKI Nadine' (length=15)
  125.           public 'Language' => string 'F' (length=1)
  126.           public 'JobNumber' => int 79593
  127.           public 'ThirdPartyCode' => string 'CB0071' (length=6)
  128.           public 'Order' => int 1
  129.           public 'DeliveryDate' => string '2015-05-19T06:29:00' (length=19)
  130.           public 'ExpectedDate' => string '2015-04-17T00:00:00' (length=19)
  131.           public 'Company' => string '001' (length=3)
  132.           public 'Establishment' => string '001' (length=3)
  133.           public 'Seq' => int 968652
  134.           public 'TrackingNumber' => string '' (length=0)
  135.           public 'Text' => string '
  136. LIVRET D ACCUEIL - WIREO - 70 PAGES (35 FEUILLETS) - 21 X 14.8 CM - Q RV
  137.  
  138. Format               rogné  21 x  14.8 cm
  139. Contenu              dessus dessous
  140.                      Intérieur 33 feuillets
  141. Prépresse            Fichier PDF fourni avec intervention
  142.                      Fichier Ã  composer ou Ã  modifier suivant vos Ã©léments : 
  143.                      Mise en page -   
  144.                      Epreuve de contrôle Ã©lectronique
  145. Impression           dessus dessous quadri au recto / quadri au verso
  146.        '... (length=1202)
  147.           public 'ShippingCompanySeq' => int 0
  148.           public 'DeliveryInfo1' => string '' (length=0)
  149.           public 'DeliveryInfo2' => string '' (length=0)
  150.           public 'DeliveryInfo3' => string '' (length=0)
  151.           public 'DeliveryInfo4' => string '' (length=0)
  152.   public 'ScheduleInfos' => 
  153.     object(stdClass)[134]
  154.       public 'ScheduleInfo' => 
  155.         array (size=14)
  156.           0 => 
  157.             object(stdClass)[135]
  158.               ...
  159.           1 => 
  160.             object(stdClass)[136]
  161.               ...
  162.           2 => 
  163.             object(stdClass)[137]
  164.               ...
  165.           3 => 
  166.             object(stdClass)[138]
  167.               ...
  168.           4 => 
  169.             object(stdClass)[139]
  170.               ...
  171.           5 => 
  172.             object(stdClass)[140]
  173.               ...
  174.           6 => 
  175.             object(stdClass)[141]
  176.               ...
  177.           7 => 
  178.             object(stdClass)[142]
  179.               ...
  180.           8 => 
  181.             object(stdClass)[143]
  182.               ...
  183.           9 => 
  184.             object(stdClass)[144]
  185.               ...
  186.           10 => 
  187.             object(stdClass)[145]
  188.               ...
  189.           11 => 
  190.             object(stdClass)[146]
  191.               ...
  192.           12 => 
  193.             object(stdClass)[147]
  194.               ...
  195.           13 => 
  196.             object(stdClass)[148]
  197.               ...
  198.   public 'JobReferences' => 
  199.     object(stdClass)[149]
  200.       public 'JobReference' => 
  201.         array (size=7)
  202.           0 => 
  203.             object(stdClass)[150]
  204.               ...
  205.           1 => 
  206.             object(stdClass)[151]
  207.               ...
  208.           2 => 
  209.             object(stdClass)[152]
  210.               ...
  211.           3 => 
  212.             object(stdClass)[153]
  213.               ...
  214.           4 => 
  215.             object(stdClass)[154]
  216.               ...
  217.           5 => 
  218.             object(stdClass)[155]
  219.               ...
  220.           6 => 
  221.             object(stdClass)[156]
  222.               ...
  223.   public 'JobSeq' => int 920179
  224.   public 'Establishment' => string '001' (length=3)
  225.   public 'Company' => string '001' (length=3)
Jun 5 '15 #15
Dormilich
8,658 Recognized Expert Moderator Expert
as suspected, it was a subresult.

with that you should find the way to access the XML string you want.
Jun 5 '15 #16
manjava
132 New Member
how can i do please

Thanks
Jun 5 '15 #17
Dormilich
8,658 Recognized Expert Moderator Expert
look at the structure of your result object as presented in the output.
Jun 5 '15 #18
manjava
132 New Member
yes i look ,can you please tell me by code script to understand

Thanks in advance
Jun 5 '15 #19
Dormilich
8,658 Recognized Expert Moderator Expert
you only understand if you try it yourself.
Jun 5 '15 #20
manjava
132 New Member
so now o have this error Undefined property and what i do simple xml or what can you please tell me what can i do to resolve this issue i waste 2 week on that

Thanks in advance
Jun 5 '15 #21
Dormilich
8,658 Recognized Expert Moderator Expert
so, which property is undefined?
Jun 5 '15 #22
manjava
132 New Member
Have this error Notice:Undefined property :stdClass::$any in c:\wamp\www\classtest.php
Jun 5 '15 #23
Dormilich
8,658 Recognized Expert Moderator Expert
sounds sensible if you look at the dump.
Jun 5 '15 #24
manjava
132 New Member
i don't understand what's you mean,but i have this issue i don't know what can i do simple xml or not to get this information attribute from the balise
so i have not luck

Thanks
Jun 5 '15 #25
Dormilich
8,658 Recognized Expert Moderator Expert
i don't know what can i do
read the d*** object structure.
Jun 5 '15 #26
manjava
132 New Member
i am not understand you can you explain please or give me the script code to understand
Jun 5 '15 #27

Sign in to post your reply or Sign up for a free account.

Similar topics

23
2549
by: Charles Law | last post by:
Does anyone have a regex pattern to parse HTML from a stream? I have a well structured file, where each line is of the form <sometag someattribute='attr'>text</sometag> for example <SPAN...
4
2540
by: Chris Bower | last post by:
Reposted from aspnet.buildingcontrols: Ok, I've got a bunch of derived controls that all have a property Rights of type Rights (Rights is an Enumerator). I wrote a custom TypeConverter so that I...
29
2871
by: gs | last post by:
let say I have to deal with various date format and I am give format string from one of the following dd/mm/yyyy mm/dd/yyyy dd/mmm/yyyy mmm/dd/yyyy dd/mm/yy mm/dd/yy dd/mmm/yy mmm/dd/yy
0
789
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
3
14032
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
1
5508
by: sandeepsangshetty | last post by:
Hi Friends, I'm unable find check box control in my webpage. When building the page I'm getting "checkbox null" and "false". Can any help me to find the solution. I'm pasting the code here. ...
4
11828
by: JJMcClaw | last post by:
Hi All, Wonder if anyone can shed any light on this error I am getting. I have the following error when trying to access my site: "Parse error: syntax error, unexpected '(', expecting T_STRING...
0
1950
by: J4Nch | last post by:
Hi, I've two network cards(ethernet). They have their own sub-network. I've to do some discovery on those subnetwork. This discovery will be made with a c# implementation of DNS-SD(Bonjour). ...
12
5043
oll3i
by: oll3i | last post by:
I am trying to run hello world app but i get an error Error: Unable to parse SDK content Please help
0
7373
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7519
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5677
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5079
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1585
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.