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

  • Home
  • SEARCH
  • 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 7017813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:57:47+00:00 2026-05-27T22:57:47+00:00

How would I pull an xml file from an external site to encode in

  • 0

How would I pull an xml file from an external site to encode in JSON? I want to be able to check if a value in the XML file is true or false but I only know how to do that with JSON and cannot find anything on how to do this with XML. This is what I am doing with JSON using a JSON API pull:

$stringData = "<a href=\"http://www.twitch.tv/coldrewbie\"</a>coL.drewbie<br>\n";
$json_file = file_get_contents("http://api.justin.tv/api/stream/list.json?channel=coldrewbie");
$json_array = json_decode($json_file, true);

if ($json_array[0]['name'] == 'live_user_coldrewbie') {
    fwrite($fh, $stringData);
}

The only problem is that the other site I want to pull from uses an XML document for its API vs having the JSON option. This is what I have but I do not think it is right although I might be somewhat close:

$xml = simplexml_load_file("http://api.own3d.tv/liveCheck.php?live_id=173952");
$json_file = json_encode($xml);
$json_array = json_decode($json, true);

if ($json_array[0]['isLive'] == 'true'){
    echo "yup";
}

Any help would be awesome!

  • 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-27T22:57:48+00:00Added an answer on May 27, 2026 at 10:57 pm

    You are on the right track. Once you have loaded the XML with this:

    $xml = simplexml_load_file("http://api.own3d.tv/liveCheck.php?live_id=173952");
    

    You can get the value of isLive node by calling the xpath method and passing it an xpath query:

    $result = $xml->xpath("/own3dReply/liveEvent/isLive");
    

    This methods returns an array, so you can either iterate the result or just print it out:

    print($result[0]);
    

    Don’t forget to check both $xml and $result before going any further with them. I have had bad experiences relying on data pulled from external websites.

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

Sidebar

Related Questions

I'm currently puling data from an external XML file and converting it to JSON
I want to pull in data using a XML::XPath parser from a XML DB
I have an XML configuration file, i want to pull one of the fields
I am trying to pull text from a single element in an xml file,
I'm using ElementTree to successfully pull values from specific tags in an xml file.
I would like to pull artifacts from teamcity. I've been trying to use c#
Would anyone be able to tell me how to pull the server name out
I am using the XmlPullParser to pull data from an XML document. My XML
I am receving an XML file as an input, whose size can vary from
I want to pull a series of relationships out of xml files and transform

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.