SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Rousse, Bulgaria
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question XML Parser class for PHP4 and PHP5

    Hi,

    Can you reccomend me XML parsing class which works with PHP4 and PHP5?
    I tested few classes and thay all did not work ok in PHP5.

  2. #2
    Resident Java Hater
    Join Date
    Jul 2004
    Location
    Gerodieville Central, UK
    Posts
    446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HTML SAX works fine on both PHP4 and 5 from my experience. If you need some tree/DOM system, you shouldn't find it too hard to write some exra classes for this.

  3. #3
    SitePoint Evangelist
    Join Date
    Dec 2003
    Location
    Arizona
    Posts
    411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by StanProg
    Hi,

    Can you reccomend me XML parsing class which works with PHP4 and PHP5?
    I tested few classes and thay all did not work ok in PHP5.
    Under PHP 5, you have lots of options. You could use a built-in class like DOM or XMLReader (from PECL, I believe). Or it would be simple enouigh to write your own. There is an example here:

    http://www.php.net/manual/en/ref.xml.php

    Thanks,

    JT

  4. #4
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Rousse, Bulgaria
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the replies,

    I want a class independent from php version (univerisal) for tree/DOM system. HTML SAX, any other modules or build-in classes did not work for me.
    The last time when I used buiding classes of PHP4 for XML I has to rewrite a lot of code(since most providers have PHP5 installed), and I'm not happy with that.
    I need one class that can use without care of enabled/installed modules or other things like that. I want it to parse my cofiguration files which are XML based.

    Thanks for the replies again

  5. #5
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP config files tend to be write once, read every time your user loads a page, things. That means that it is an easy place to put some performance updates in. Instead of an XML tree, you could use a tree of associated arrays. The code would look like this:

    PHP Code:
    // in your header file

    $config = include('conf.php');

    // inside conf.php:

    return array(
      
    'database' => array(
        
    'host' => 'localhost',
        
    'username' => 'root',
        
    'password' => ''
        
    ),
      
    'templates' => array(
        
    'path' => '/templates'
        
    )
      ); 
    And so on. Propel uses an XML reader to produce an associative array that can be loaded in PHP like the above example. You could probably hack out this component for use in your projects. Not sure what the Propel licence looks like.

    hth,
    Douglas
    Hello World

  6. #6
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Rousse, Bulgaria
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Doug, I'll think about that.


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
  •