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
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
  • 2
  • 2
LVL 110

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 110

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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

691 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