Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PHP5 > Easiest way to parse SOAP/XML string?

Posted on 2009-04-05
8
Medium Priority
?
701 Views
Last Modified: 2013-11-18
I'm getting the attached SOAP/XML string back from an API.  I'm looking for the easiest/best way of parsing it into an array/object so I can access the data.  I tried using SimpleXMLElement() but it wasn't able to parse it, it just returned a blank - no errors, no nothing.
<?php
$xmlData = new SimpleXMLElement($the_attached_data);
echo '<pre>';
var_dump($xmlData);
//Returns:  object(SimpleXMLElement)#1 (0) {}
?>

Open in new window

SOAP-XML-String.txt
0
Comment
Question by:Geoff Millikan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 39

Expert Comment

by:Roger Baklund
ID: 24073163
If you use specialized functions for SOAP, it will be easier. There is a builtin soapclient class:

http://php.net/manual/en/class.soapclient.php

And this is a good open source (LGPL) alternative:

http://sourceforge.net/projects/nusoap/
http://www.scottnichol.com/nusoapintro.htm
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 24073253
Try this and see if you can't find more of the object.

HTH, ~Ray
<?php
$xmlData = SimpleXML_Load_String($the_attached_data);
echo '<pre>';
var_dump($xmlData);
//Returns:  object(SimpleXMLElement)#1 (0) {}
?>

Open in new window

0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 24073278
Better yet, try some code that actually got tested!
;-)


<?php // RAY_temp_hates_soap.php
error_reporting(E_ALL);
echo "<pre>";
 
// TEST DATA
$xml = ' [ INSERT YOUR SOAP XML STRING HERE] ';
// END TEST DATA
 
// MUNG THE TEST DATA
$xml = str_replace('soap:', 'soap_', $xml);
 
// MAKE AN OBJECT
$obj = SimpleXML_Load_String($xml);
var_dump($obj);

Open in new window

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:Geoff Millikan
ID: 24073398
cxr: Although you'd think that the SoapClient() would be cool, and believe me I wish it were, it is not.  In fact, SOAP in general is yucky.  SOAP is like Brussels sprouts - you can put as much cheese topping on them as you like, but they still are not very good.  Which is probably why you just gave me the link to the RTFM on the SoapClient() instead of providing an example of how to do it.  Not trying to give you a hard time, just driving home the point that nobody wants to do SOAP.  Again, for example: http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_24291253.html

Ray, your solution works.  Obviously I'm enjoying the "RAY_temp_hates_soap.php" name.
0
 

Author Comment

by:Geoff Millikan
ID: 24073404
How did you know to exchange 'soap:' and 'soap_'?  Experience?
0
 

Author Comment

by:Geoff Millikan
ID: 24101872
Ray, saw your name on the PHP boards at the link below.  Never realized you were famous... ;-)   Thanks for your help on so many questions.

http://www.php.net/manual/en/function.base-convert.php
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 24108122
@t1shopper: Thanks for the points!

"How did you know to exchange 'soap:' and 'soap_'?  Experience?" Yup, nothing more!

Regarding the PHP.net post, I have made several of those over the years (varying in importance and quality, to be sure) and have found the PHP community to be amazingly responsive and helpful.  Several years ago I posted an algorithm to determine the date of Easter and today it is a built-in function in PHP:
http://us3.php.net/manual/en/function.easter-date.php

Having said that, I find the back-and-forth dialog here at EE to be a great learning tool.  Glad I was able to be helpful to you here.

Best, ~Ray
0
 

Author Comment

by:Geoff Millikan
ID: 24108231
Nicely done.   We wouldn't be where we are today without the PHP help we've received from you and others here at EE.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question