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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:31:15+00:00 2026-05-30T16:31:15+00:00

The setup: I have an external XML file I have no control over, here

  • 0

The setup:

I have an external XML file I have no control over, here is it:

001.xml

<?xml version="1.0" encoding="utf-8"?>
<Gallery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ID="001" Name="001">
<Images>
<ImageGalleryEntry Name="1 John" Description="Doe" FileName="830358.1john.png" Width="100" Height="100">
<S3Key>accounts/b2d174c1-a408-4d58-9d48-1490ac4e9f9b/site-37857/cms-assets/images/830358.logooraclehealthsciencesthumb.png</S3Key>
<S3ThumbnailKey>accounts/b2d174c1-a408-4d58-9d48-1490ac4e9f9b/site-37857/cms-assets/thumbnails/830358.logooraclehealthsciencesthumb.png</S3ThumbnailKey>
<ContentLength>1309</ContentLength>
</ImageGalleryEntry>
<ImageGalleryEntry Name="11 Jane" Description="Doet" FileName="943702.11jane.png" Width="100" Height="100">
<S3Key>accounts/b2d174c1-a408-4d58-9d48-1490ac4e9f9b/site-37857/cms-assets/images/943702.logorochethumb.png</S3Key>
<S3ThumbnailKey>accounts/b2d174c1-a408-4d58-9d48-1490ac4e9f9b/site-37857/cms-assets/thumbnails/943702.logorochethumb.png</S3ThumbnailKey>
<ContentLength>1403</ContentLength>
</ImageGalleryEntry>
<ImageGalleryEntry Name="10 Jack" Description="Smith" FileName="965501.10jack.png" Width="100" Height="100">
<S3Key>accounts/b2d174c1-a408-4d58-9d48-1490ac4e9f9b/site-37857/cms-assets/images/965501.pwclogo.png</S3Key>
<S3ThumbnailKey>accounts/b2d174c1-a408-4d58-9d48-1490ac4e9f9b/site-37857/cms-assets/thumbnails/965501.pwclogo.png</S3ThumbnailKey>
<ContentLength>7021</ContentLength>
</ImageGalleryEntry>
</Images>
</Gallery>

I also have a php code that takes this info and puts it out in html nicely:

index.php fragment

<?php
$url = '001.XML';
$xml = simplexml_load_file($url);
foreach($xml->Images->ImageGalleryEntry as $item) {
    echo $item['FileName'] . "<br/>" . $item['Name'] . "<br/>" . $item['Description'] . "<br/><br/>";
};
?>

The output is:

830358.1john.png
1 John
Doe

943702.11jane.png
11 Jane
Doet

965501.10jack.png
10 Jack
Smith

The problem is that I actually need it ordered by the Name attribute, like this:

830358.1john.png
1 John
Doe

965501.10jack.png
10 Jack
Smith

943702.11jane.png
11 Jane
Doet

Note that the XML constantly changes, so the php should automatically order them alphabetically by Name. I’m guessing I need to somehow sort alphabetically all the ImageGalleryEntry tags by their Name attribute before entering the for each loop, but no clue how to do that.

Please provide an actual way to do it, I’m new to php, and won’t know what to do if you say something like “make an array”.

  • 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-30T16:31:16+00:00Added an answer on May 30, 2026 at 4:31 pm

    You need to use usort. This should work:

    <?php
    $url = '001.XML';
    $xml = simplexml_load_file($url);
    
    $items = array();
    foreach($xml->Images->ImageGalleryEntry as $item) {
        $items[] = $item;
    };
    
    // Custom sort on the names of the items:
    usort ($items, function($a, $b) {
        return strcmp($a['Name'], $b['Name']);
    });
    
    foreach ($items as $item) {
        echo $item['FileName'] . "<br/>" . $item['Name'] . "<br/>" . $item['Description'] . "<br/><br/>";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have setup a SenchaTouch/PhoneGap app that pulls information from an external XML feed.
I have setup a polling system, where when you vote it stores your external
I have setup a simple Oracle external table test that I (alongside a DBA
I have a SVN external setup in my code which pulls all the code
I have setup my project in SVN to use an external library. When I
I have created a Windows setup file for my Windows project in Visual Studio
In production I have setup an external folder to upload and display images from
I have and external JS scripts file with all my objects in that runs
I have an external JSON file that has this in it: { Home: [
Setup Have you ever had the experience of going into a piece of code

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.