Receive cXML Example

Posted on 2008-10-22
Last Modified: 2013-11-18
I'm looking for example Php code for receiving cXML, parsing, and returning responce cXML.

I believe the xml will be received as a form post via HTTP, so I assume I need to loop through  $_POST.
Question by:ncw
  • 2
  • 2
LVL 108

Accepted Solution

Ray Paseur earned 500 total points
ID: 22776873
Here is the link to the man pages for cXML

The XML file will probably be received as a string - it may come via $_POST, but it does not need to be processed as an array.  You can use SimpleXML to process it.

See the code snippet for an example of using SimpleXML to extract information from an XML doc.  In this example, it happens to be information from the Yahoo geocoder, but the principles are the same for any XML.

Best regards, ~Ray

$ydata	= new SimpleXMLElement($y_buf);

$y_lat	= $ydata->Result->Latitude;

$y_lon	= $ydata->Result->Longitude;

$y_zip	= $ydata->Result->Zip;

Open in new window


Author Closing Comment

ID: 31528165
Thanks for your comments Ray. Yes I had seen the cXML UsersGuide.pdf before, that was my starting point but I didn't find it very useful for providing example code. Unfortunately this project has stalled but I'm hoping it will restart in the New Year.
LVL 108

Expert Comment

by:Ray Paseur
ID: 23226106
Thanks for the points, and best wishes for the new year! ~Ray

Author Comment

ID: 23838607
I found the xml in $GLOBALS['HTTP_RAW_POST_DATA']

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jQuery detect if it is a mobile device 3 90
simplest php form 3 57
Php pie charts 3 26
How to keep line breaks when outputting data from database 4 13
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
The viewer will learn how to count occurrences of each item in an array.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

947 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now