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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:16:01+00:00 2026-05-17T21:16:01+00:00

I have an XML File: <?xml version=1.0 encoding=iso-8859-1?> <deadlines> <deadline> <date>2010-07-01</date> <text>Residency Application for

  • 0

I have an XML File:

<?xml version="1.0" encoding="iso-8859-1"?>
<deadlines>
    <deadline>
        <date>2010-07-01</date>
        <text>Residency Application for Fall Due</text>
    </deadline>
    <deadline>
        <date>2010-06-01</date>
        <text>Residency Application for Summer Due</text>
    </deadline>
    <deadline>
        <date>2010-07-20</date>
        <text>Summer Bill Due</text>
    </deadline>
</deadlines>

When I load the file into a PHP script using simplexml_load_file(), I get the following:

SimpleXMLElement Object
(
    [deadline] => Array
        (
            [0] => SimpleXMLElement Object
                (
                    [date] => 2010-07-01
                    [text] => Residency Application for Fall Due
                )

            [1] => SimpleXMLElement Object
                (
                    [date] => 2010-06-01
                    [text] => Residency Application for Summer Due
                )

            [2] => SimpleXMLElement Object
                (
                    [date] => 2010-07-20
                    [text] => Summer Bill Due
                )

        )

)

In order for my script to handle the XML file as an array, I need to parse the file and get it into this format:

Array
(
    [0] => SimpleXMLElement Object
        (
            [date] => 2010-07-01
            [text] => Residency Application for Fall Due
        )

    [1] => SimpleXMLElement Object
        (
            [date] => 2010-06-01
            [text] => Residency Application for Summer Due
        )

    [2] => SimpleXMLElement Object
        (
            [date] => 2010-07-20
            [text] => Summer Bill Due
        )

)

IS there a PHP function to convert the XML file? 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-05-17T21:16:02+00:00Added an answer on May 17, 2026 at 9:16 pm
    $deadlines = array();
    $sxe = new SimpleXmlElement($xml);
    foreach($sxe->deadline as $deadline) {
        $deadlines[] = $deadline;
    }
    print_r($deadlines);
    

    or

    $sxe = (array) new SimpleXmlElement($xml);
    print_r( $sxe['deadline'] );
    

    EDIT sorry, I assumed you were familiar enough with SimpleXml to know that the constructor of SimpleXmlElement assumes you are passing the XML as a string. Either change the line to read

    $sxe = new SimpleXmlElement($filename, NULL, TRUE);
    

    or replace it with

    $sxe = simplexml_load_file($filename);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have following xml file as input .... <?xml version=1.0 encoding=ISO-8859-1?> <T0020 xsi:schemaLocation=http://www.safersys.org/namespaces/T0020V1 T0020V1.xsd
I have the following XML <?xml version=1.0 encoding=ISO-8859-1?> <?xml-stylesheet type=text/xsl href=example3.xsl?> <pics> <page no=1>
I have an XML file like the following : <?xml version=1.0 encoding=ISO-8859-1 ?> <mylist
I have a XML File like that <?xml version=1.0 encoding=utf-8 ?> <Configurations> <EmailConfiguration> <userName>xxxx</userName>
I have the following XML: <?xml version=1.0?> <?xml-stylesheet type=text/xsl href=http://www.test.com/AuditTrail.xsl?> and XSL: <?xml version=1.0
I have an XML file that starts like this: <Elements name=Entities xmlns=XS-GenerationToolElements> I'll have
I have an xml file providing data for a datagrid in Flex 2 that
I have an XML file, which I open in F# like this: let Bookmarks(xmlFile:string)
I have an xml file where I need to comment out a whole piece
I have an XML file loaded into a DOM document, I wish to iterate

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.