Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7994039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:01:48+00:00 2026-06-04T14:01:48+00:00

So i’m working on a php script which passes information to a server using

  • 0

So i’m working on a php script which passes information to a server using Curl and the POST method and then takes back information from that server in the form of XML.I then want to take this information and parse it into a readable format for the user.

I grab the information using curl and load it into a variable ($result) which i then want to load into simpleXML and store in the variable $routeinfo. However when I perform a var_dump($routeinfo) there doesn’t appear to be any data stored. I’ve confirmed that there is data present in $result by echoing it.

I also figured it may have been due to the XML not showing up in the browser when I echoed $result(but it is there if I check the source). Just to check though I used htmlentities but that causes a lot of errors because < is interpreted as it’s html equivalent. Anyway I’ve reached an impass and have logged quite a few hours implementing different suggestions to no avail. My code is below and I would appreciate any help that can be rendered.

<?php 
//retrieve form data in a variable
$input = $_POST['stopNo'] ;

//declare other variables needed
$api_key = 'xxxkey' ;
$api_id = 12345 ;
$url = 'url to send data to' ; 
$querystring = "appID=". $api_id . "&apiKey=" . $api_key . "&stopNo" . $input ;
$data = urlencode($url) ; 


//curl using

$ch = curl_init() ; 

//set up curl

curl_setopt($ch, CURLOPT_URL, 'urlsendingdatato');
curl_setopt($ch, CURLOPT_POSTFIELDS, 'appID='.urlencode($api_id).'&apiKey=' .urlencode($api_key) . '&stopNo=' .urlencode($input) );
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0 ) ; 
curl_setopt($ch, CURLOPT_ENCODING, "UTF-8") ;
curl_setopt($ch, CURLOPT_BINARYTRANSFER , TRUE) ;


//execute and gather info
$result = curl_exec($ch) ; 

//close connection
curl_close($ch) ;

//format data 
//ent at the moment serves no purpose doesn't render the information correctly
$ent = htmlentities($result);
$routeinfo = new SimpleXMLElement($result) ;

//print data
echo "<br> $result <br>" ; 
var_dump($routeinfo) ;


?> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T14:01:50+00:00Added an answer on June 4, 2026 at 2:01 pm

    It seems that the problem is arising when the simpleXML object is created.
    So you can try creating a new simpleXMLElement object with a well defined XML file. If that works that means the fetched xml file is not of proper format.

    $xml="<?xml version='1.0'?><book><author>steve</author><price>200</price><name>Its my life</name></book>";
    $test= new SimpleXMLElement($xml);
    var_dump($test);
    

    This works for me!

    But generally if there is an xml parsing issue, simpleXMLElement throws a error . Did it return any error in your case? or maybe you have switched off error reporting (error_reporting(0); ).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.