[Webinar] Streamline your web hosting managementRegister Today


Parse Soap Response with SimpleXML problem

Posted on 2010-04-02
Medium Priority
Last Modified: 2013-11-18
So I am making a soap call in PHP using fopen.  I cannot figure out how to parse to a specific value in the soap env response to save my life.

I have been Topekaing( errr Googleing) this for hours and have tried everything from declare namespaces to removing the colons etc...

Any help woudl be appreciated!
//soap req env

$contents = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">

//Soap Response

<?xml version='1.0' encoding='utf-8'?>
	<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
		<soapenv:Header />
			<ns2:PayResponse xmlns:ns2="http://svcs.paypal.com/types/ap">

Open in new window

Question by:lharrispv
1 Comment
LVL 82

Accepted Solution

hielo earned 2000 total points
ID: 29507220
This issue is discussed here:

Basically, they are getting rid of the colon between the namespace and the tag name:
$xmlString = preg_replace("/(<\/?)(\w+):([^>]*>)/", "$1$2$3", $response);

then they load the "clean" xml (which is now in $xmlString) into simple xml

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

607 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