Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2007
    Posts
    73

    PHP, reading from an xml file

    Hello again,

    I'm trying to set up an automated e-mail proccess to send me information about a proccess that is being logged, this is mostly irrelevent however here is the question anyways.

    I hate data stored in an xml sheet like so

    Code:
    <itemlog>
      <item id="1277106687900" name="name" time="Mon 06/21/10 12:21">"Some stuff </item>
    </itemlog>
    This file is saved as log.xml and is in the same folder as the php script.

    I would like to open up the .xml file, probably using fopen and then read the file using fread and then display the data, probably in an array for the best use, ie

    echo $itemID[0], $name[0], $time[0] and then the "some stuff part"

    I'm sure there is a simple way to do this but searching hasn't gotten me and relevent results.
    Last edited by Shib; 06-21-2010 at 01:23 PM.

  2. #2
    Join Date
    Jan 2006
    Location
    Athens, Greece
    Posts
    1,481
    Try simplexml
    PHP Code:
    $xml simplexml_load_string($string);
    print_r($xml); 
    http://php.net/manual/en/book.simplexml.php

  3. #3
    Join Date
    Jun 2007
    Posts
    73
    Hmm thank you Steve,

    Would it be to much to ask if you could quickly write a few lins of code that selects the item and then asigns its variables or point me in the right direction?

    I understand if you say no,

    Thanks regardless

Similar Threads

  1. AJAX: Weird problem. (PHP-XML-> JS) XML not parsed properly
    By monilchheda in forum Programming Discussion
    Replies: 5
    Last Post: 05-23-2006, 11:52 AM
  2. Reading file
    By UrlGuy in forum Programming Discussion
    Replies: 6
    Last Post: 07-27-2005, 12:47 PM
  3. PHP: Reading file line by line
    By UrlGuy in forum Programming Discussion
    Replies: 11
    Last Post: 07-26-2005, 04:11 PM
  4. Need help with php/xml grabing info from xml sheet placing into php.
    By rhinohost.net in forum Programming Discussion
    Replies: 8
    Last Post: 04-07-2005, 04:50 AM
  5. Load a XML RSS Feed with a .php file to RSS Client
    By Idezo in forum Programming Tutorials
    Replies: 1
    Last Post: 08-03-2004, 12:09 PM

Posting Permissions

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