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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:13:26+00:00 2026-06-05T17:13:26+00:00

I am trying to parse data from the XML below (I shortened the data

  • 0

I am trying to parse data from the XML below (I shortened the data a lot to give an example of what the data looks like).

For each attribute, I would need to store the data in a separate array.

XML File

<report>
    <title>Resolution Times (Jun 07 00:21)</title>
    <sets>
        <set>
            <legend>Solved in Less than 2 Hours</legend>
            <values>
                <value data="8702" date="2012-05-24"/>
                <value data="8741" date="2012-05-25"/>
                <value data="8741" date="2012-05-26"/>
                <value data="8741" date="2012-05-27"/>
            </values>
        </set>
        <set>
            <legend>Solved in Less than 24 Hours</legend>
            <values>
                <value data="36990" date="2012-05-24"/>
                <value data="37094" date="2012-05-25"/>
                <value data="37096" date="2012-05-26"/>
                <value data="37144" date="2012-05-27"/>
            </values>
        </set>
    </sets>
</report>

Below is some test code I am doing to try and read in the data. For testing purposes I am just printing out to see what data is actually pulled.

$verifyReport = new SimpleXMLElement('305262.xml', null, true);
$testing = $verifyReport->sets->set->values->value;

echo '<ol>';
foreach($testing as $data)
{
    echo '<li>',
    $data['data'].PHP_EOL;
    echo '</li>';
}

echo '</ol>';

$testing1 = $verifyReport->sets->sets->values->value;

echo '<ol>';
foreach($testing1 as $data2)
{
    echo '<li>',
    $data2['data'].PHP_EOL;
    echo '</li>';
}

echo '</ol>';

Below is out the output of the data

1. 8702
2. 8741
3. 8741
4. 8741

Warning: Invalid argument supplied for foreach() in 
/Applications/XAMPP/xamppfiles/htdocs/tango/test.php on line 23

I am able to pull in the first set (Solved in Less than 2 hours) ok, but when I try to pull the data from the second set (Solved in Less than 24 Hours), I get the above error.

Can anyone help correct this issue?

  • 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-05T17:13:27+00:00Added an answer on June 5, 2026 at 5:13 pm

    In the second block you have $testing1 = $verifyReport->sets->sets->values->value; So I guess the second sets has to be set instead. But anyway, why don’t you iterate over $verifyReport->sets and read the further values inside of your for loop?

    new SimpleXMLElement('305262.xml', null, true);
    foreach ($verifyReport->sets->set as $set) {
        echo '<ol>';
        foreach ($set->values->value as $data) {
            echo '<li>',
            $data['data'] . PHP_EOL;
            echo '</li>';
        }
        echo '</ol>';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to parse data from Archive.org's search functionality. The data looks like this:
I am trying to parse data from a xml page through sax parsing technique.The
I am trying to parse data from a xml web service but I am
I'm trying to parse some XML from the USGS. Here's an example The parameterCd
I am trying to parse data from commoncrawl.org using hadoop streaming. I set up
I am trying to parse some data from ifconfig output with sed, but I
I'm trying to load and parse json data from an external source into a
I am trying to fetch data from internet, parse it and then show the
I'm trying to parse the output from a tool into a data structure but
I'm getting the following error when trying to add some data from myXml.xml to

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.