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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:09:19+00:00 2026-05-13T07:09:19+00:00

I have a page on a remote server that returns a single xml value

  • 0

I have a page on a remote server that returns a single xml value

<?xml version="1.0" ?><Tracker>12345</Tracker>

How do I go about getting the value 12345 or whatever is in the tag into a PHP variable?
I know I can’t do something as simple as:

<?php
    $var = http://www.www.com/file.php;
    echo $var;   //12345
?>

I’m new to the entire idea of creating a web service – I think that’s what this should be.?.

  • 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-13T07:09:20+00:00Added an answer on May 13, 2026 at 7:09 am

    You have to go in two steps :

    • Get the XML string from the remote server
      • with curl, for instance
      • or with file_get_contents
    • and, then, parse that XML to extract the data
      • with simplexml_load_string for instance

    Note that those two steps can be merged as one, using simplexml_load_file, if the configuration of your server allows you to do that.

    Once you have that XML in a PHP variable, using SimpleXML, it’s quite easy to get the value you want. For instance :

    $string = '<?xml version="1.0" ?><Tracker>12345</Tracker>';
    $xml = simplexml_load_string($string);
    echo (string)$xml;
    

    Will get you

    12345
    

    And getting the content of that XML from the remote URL can be as simple as :

    $string = file_get_contents('http://your-remote-url');
    

    And if you can do that, you can also use that remote URL directly with SimpleXML :

    $xml = simplexml_load_file('http://your-remote-url');
    echo (string)$xml;
    

    But this will only work if allow_url_fopen is enabled in your server’s configuration.

    If allow_url_fopen is disabled on your server, you can get the XML from the remote server using curl ; something like this should do the trick, for instance :

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "http://your-remote-url");
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $string = curl_exec($ch);
    curl_close($ch);
    

    And, then, you can still use simplexml_load_string, as I did in my first example.

    (If using curl, take a look at the documentation of curl_setopt : there are several options that might interest your — for instance, to specify timeouts)

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

Sidebar

Ask A Question

Stats

  • Questions 513k
  • Answers 513k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Start with LINQ. It is a core concept in the… May 16, 2026 at 5:56 pm
  • Editorial Team
    Editorial Team added an answer It generally depends on how the remote site handles state… May 16, 2026 at 5:56 pm
  • Editorial Team
    Editorial Team added an answer See the Targeted Device Family setting in your Target settings.… May 16, 2026 at 5:56 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a page on a server at a remote location that only displays
I have a coldfusion 8 webservice that returns an array <cffunction access=remote name=testMethod returntype=array>
We have a asp.net 2.0 web application that is running on IIS7. It is
I have a web application that I upload an image to, the image is
I have Application written with GWT 1.7. I have one page where I upload
driving me nutso.... I have a .Net 2.0 webservice that takes a string and
I am trying to have a php script that displays a url with user
I have a page with a <script> tag in it pointing to a PHP
I have searched for two weeks, every night, exhaustively reading forum threads and trying
I have a problem downloading particular file types by WebClient. So there are no

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.