SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Order in which XML files are loaded

    Scenario:
    I have seven xml files in a directory on my webserver and I use the simplexml_load_file function to load each one via a while loop and the readdir function, just as is advised in the book 'XML Web Development with PHP', by Thomas Myer.

    Question
    What criteria determine the order in which the XML files are loaded. Let's assume the files are of this nomenclature:

    • [1.] = webcopy20070416153002.xml
    • [2.] = webcopy20070416154102.xml
    • [3.] = webcopy20070416173103.xml
    • [4.] = webcopy20070416192000.xml
    • [5.] = webcopy20070416201502.xml
    • [6.] = webcopy20070416210023.xml
    • [7.] = webcopy20070416210207.xml


    I can't make sense of it right now and I've tried renaming XML files and recerating them with new date stamps..etc,

    I know I can force it by throwing the whole slew in an array and presorting but I'd like to understand what is determining the order without a forced sort.

    Is it readdir and a file datestamp (unix)server side?

    Much obliged for any offerings on this,

    R

  2. #2
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As i can see these are currently sorted with their name as i can see the file names listed in your example. And by default the file name and in the ascending order as i know so far.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  3. #3
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rajug View Post
    As i can see these are currently sorted with their name as i can see the file names listed in your example. And by default the file name and in the ascending order as i know so far.
    Thanks but perhaps I wasn't very clear. Let me try this again.

    On a Unix server, when I simply load each XML file and parse its content there appears to be no discernible pattern in how the XML documents are processed. This differs from windows.

    If I change the XML filenames on a unix server, or their timestamp on a unix server or their byte size on the unix server, they are loaded and processed in a haphazard manner. However when I place them on a Windows system they are ordered and processed according to their timestamp.

    I noticed this problem because I developed my CMS on a Windows system and then uploaded to a unix server.

    So again I ask what determines how they are ordered and processed on a unix server.

  4. #4
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know the answer to your question, but it will be safer just to read all the filenames on the dir, order them and then process them.

  5. #5
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes that would be safest but if anyone learns what the actual reason is behind the processing I hope they'll post it. Thx

  6. #6
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe the unix os uses last modified timestamp.
    The Windows os uses date created.
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •