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

The Archive Base Latest Questions

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

I am trying to import a XML file via API into my php script

  • 0

I am trying to import a XML file via API into my php script which then will parse said XML file and extract a string. Ive searched across the webspace for an answer, and though I have found a ton of resources I still cannot get this script to work.

The XML file that I am loading will look something like this

<api version="2">
  <currentTime>2012-07-28</currentTime>
    <result>
      <rowset name="accounts" key="accountID" columns="accountID,accountKey,balance">
        <row accountID="555555555" accountKey="6666" balance="7777777777.23"/>
      </rowset>
    </result>
  <cachedUntil>2012-07-28</cachedUntil>
</api>

I am trying to get my php script to fetch the value of the attribute balance.
This is the code that I have put together so far:

<?php

$apiurl = "api.some-arbitrary-api-site.com;
$xml = simplexml_load_file($apiurl);

print_r($xml);
$balance = $xml->balance;
print_r($balance);    

?>

This returns:

SimpleXMLElement Object ( ) 

Also following some other web tutorials I have tried this change

$balance = $xml->row->attributes()->balance;
print_r($balance);

Which spits out

Warning: main() [function.main]: Node no longer exists in C:\xampp\htdocs\EVE\progress\import.php on line 22

Warning: main() [function.main]: Node no longer exists in C:\xampp\htdocs\EVE\progress\import.php on line 22

What am I doing wrong? The end result is for the page to load this API and fetch the balance once every two days and store the data to be used in a chart rendered using highchart.

Any help will be appreciated!
Thanks

  • 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-08T14:48:05+00:00Added an answer on June 8, 2026 at 2:48 pm

    Musa answered the question

    I don’t know simplexml but shouldn’t it be
    $xml->result->rowset->row->attributes()->balance – Musa

    I was being an idiot and didnt check the xml over again when typing in the path.

    Thanks

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

Sidebar

Related Questions

Im trying push some data into a CRM system via an XML import. I
I'm trying to import an xml file into vb.net XmlDocument but am getting the
I am trying to import a flat file into a SQL Database via Biztalk
I am trying to import an XML file into MS Access 2003, through File>Get
I have been trying to parse a file with xml.etree.ElementTree : import xml.etree.ElementTree as
I'm trying to create an XML output file to import into another program. The
I'm trying to import an XML file that contains a list of points for
I'm trying to import an XML that's provided by twitter into a readable format
I've got some XML I'm trying to import with c#, which looks something like
I'm currently trying to import about 10000 rows (from a CSV file) into an

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.