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 6639747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:35:27+00:00 2026-05-25T23:35:27+00:00

I am sending a XML to a webserver using PHP, and the server returns

  • 0

I am sending a XML to a webserver using PHP, and the server returns an XML response. I need help parsing values from the response! I have read the SimpleXML instructions, but my understanding is that all those are only for when XML data is already created, but needs to be parsed. This is my PHP script so far:

<?php
$ch = curl_init("http://api.online-convert.com/queue-insert");
$count = $_POST['count'];
$file = "testdoc2.txt";
$fh = fopen( $file, 'w' );
$carriageReturn = "\n";
fwrite( $fh, $count );
fclose( $fh );

$request["queue"] = file_get_contents($count);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
$response = curl_exec($ch);
curl_close ($ch);
echo $response;

$xmlstr = simplexml_load_string($response);

$file = "testdoc.txt";
$fh = fopen( $file, 'w' );
$carriageReturn = "\n";
fwrite( $fh, $xmlstr);
fclose( $fh );


?>

The XML response that needs to be parsed is this:

<?xml version="1.0" encoding="utf-8"?>
<queue-answer>
  <status>
    <code>0</code>
    <message>Successfully inserted job into queue.</message>
  </status>
  <params>
    <downloadUrl>http://www.online-convert.com/result/35f6ddbcc2ca58e7e98addc7c2efd6eb</downloadUrl>
    <hash>35f6ddbcc2ca58e7e98addc7c2efd6eb</hash>
  </params>
</queue-answer>

I just need to extract the value and show it to the user. I am an iPhone developer.

  • 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-05-25T23:35:27+00:00Added an answer on May 25, 2026 at 11:35 pm

    You first have to create the request xml document and send it to the server, e.g. (without error handling et al and without testing because of missing api key):

    $request = new SimpleXMLElement('<queue><apiKey/><targetType/><targetMethod/><testMode/><sourceUrl/></queue>');
    $request->apiKey = 'abcdefghijklmnopqrstuvwx';
    $request->targetType = 'image';
    $request->targetMethod = 'convert-to-jpg';
    $request->testMode = 'false';
    $request->sourceUrl = 'http://whatever';
    $ch = curl_init("http://api.online-convert.com/queue-insert");
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, array('queue'=>$request->asXml()));
    $response = curl_exec($ch);
    // TODO: might want to test the response code here, see curl_get_info/CURLINFO_HTTP_CODE
    curl_close ($ch);
    

    then you need to parse the response

    $queueAnswer = simplexml_load_string($response);
    echo 'status code:', $queueAnswer->status->code;
    // in case of success you should be able to access the values via
    echo ' url:', queueAnswer->params->downloadUrl;
    echo ' hash:', queueAnswer->params->hash;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Scenario: Sending XML, generated using php, via cURL to an external server for parsing.
I need help with downloading from webserver... What i currently do is get XML
Sending XML from C# Server and receiving it it in Android Java client This
I am parsing an XML coming from a web server and the parsing sometimes
I am sending an xml response from my servlet to my html page. I
I'm trying to parse XML in an Ajax response. When the server returns a
I am coding a PHP rest Service. I am sending xml string from client
I'm working towards sending an XML request to a URL using cURL in PHP.
sending mail along with embedded image using asp.net I have already used following but
I sending ajax request from a jQuery file like below, which expects response in

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.