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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:05:35+00:00 2026-05-24T04:05:35+00:00

I have a very simple XML file: <?xml version=1.0 encoding=ISO-8859-1?> <Data><Day Num=4197> <Date>270611</Date> <Energy>47</Energy>

  • 0

I have a very simple XML file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<Data><Day Num="4197">
<Date>270611</Date>
<Energy>47</Energy>
</Day>
<Day Num="4219">
<Date>190711</Date>
<Energy>202</Energy>
</Day>
<Day Num="4220">
<Date>200711</Date>
<Energy>17074</Energy>
</Day>
<Day Num="4221">
<Date>210711</Date>
<Energy>11563</Energy>
</Day>
<Day Num="4222">
<Date>220711</Date>
<Energy>18178</Energy>
</Day>
<Day Num="4223">
<Date>230711</Date>
<Energy>24916</Energy>
</Day>
<Day Num="4224">
<Date>240711</Date>
<Energy>10555</Energy>
</Day>
<Day Num="4225">
<Date>250711</Date>
<Energy>12683</Energy>
</Day>
</Data>

With some help on here yesterday I got it to pull out Date and Energy, but now I want to display Day Num.

I did a print_r($xml); which shows:

   SimpleXMLElement Object
(
    [Day] => Array
        (
            [0] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                        (
                            [Num] => 4197
                        )

                    [Date] => 270611
                    [Energy] => 47
                )

            [1] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                        (
                            [Num] => 4219
                        )

                    [Date] => 190711
                    [Energy] => 202
                )

So the Num field I want is in an array, but I cannot figure out how to extract it?

My current code is very simple, it is:

$xml = simplexml_load_file("DATA.XML");


foreach($xml->children() as $day)
{
    list($date, $energy) = $day->children();
    echo ',Date: ' . $date . ', Energy: ' . $energy . '<br />';
}

How would I extract Day Num please?

  • 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-24T04:05:37+00:00Added an answer on May 24, 2026 at 4:05 am

    Use: $day->attributes()->Num

    See: SimpleXMLElement::attributes for further reading.

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

Sidebar

Related Questions

I have very simple persistance.xml file: <?xml version=1.0 encoding=UTF-8?> <persistence version=1.0 xmlns=http://java.sun.com/xml/ns/persistence xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://java.sun.com/xml/ns/persistence
I have a simple XML file like this: <?xml version=1.0 encoding=UTF-8?> <?xml-stylesheet type=text/xsl href=01C3_OIZODEMO_certificato_v1.0.xsl?>
I have a map that reads an XML file; it's all very simple and
I have this XML file: <?xml version=1.0 encoding=utf-8?> <Wpf> <wpfctrl id=NavBtnTemplate>#FFCFDEFF</wpfctrl> </Wpf> and i
I have a very simple xml file that I would like to create a
I have some very simple XML: <properties> <property> <name>BobFish</name> <explaination>Bob is a fish.</explaination> </property>
I have a very simple python script that should scan a text file, which
Somehow I can't read an XML file with very simple structure in my PowerShell
I have a very simple xml content videolar.xml . Flash player takes these elements
This is my xml file: <?xml version=1.0 encoding=UTF-8?> <CONTACTS> <CONTACT> <FirstName>Arun</FirstName> <LastName>Arun_Neelam</LastName> <Email>nuraaa_iceee@yahoo.co.in</Email> </CONTACT>

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.