XML Parsing with PHP4

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
PhreaK
Forum Newbie
Posts: 2
Joined: Tue Apr 25, 2006 8:44 am
Location: Brisbane, Australia

XML Parsing with PHP4

Post by PhreaK »

Hi, i've only recently started programming in php and am in the middle of developing a LAMP driven site (http//www.pipod.tv). I have been testing it locally using php5 and things have been going well but when I uploaded it the the machine it will be hosted on it didn't go quite as smoothly as planned. After a bit of debugging i managed to locate simplexml_load_string as the source of my problems. Basically its a php5 thing and the host only runs php4. Is there a php4 equivalent or am I going to have to right a new xml parsing class?
User avatar
cj5
Forum Commoner
Posts: 60
Joined: Tue Jan 17, 2006 3:38 pm
Location: Long Island, NY, USA

Post by cj5 »

Dude,

If you read the manual, simplexml_load_string, this function is only available in PHP5. I would suggest using xml_parse, and make sure the server has the expat library configured with PHP, or reinstall PHP4 with it. Or you can just upgrade to PHP5 if that is possible. That's some pretty good stuff for just starting PHP!

Cheers...
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

parse into struct / array.. And then you can iterate over that array more or less like you'd use simplexml...
User avatar
PhreaK
Forum Newbie
Posts: 2
Joined: Tue Apr 25, 2006 8:44 am
Location: Brisbane, Australia

Post by PhreaK »

Thanks for the quick replies.

cj5: I now know that simplexml_load_string is only in php5, hence this post. Unfortunately i don't have access to the server this will be on as it with a hosting company so upgrading or installing additional modules isn't possible, but i will look further into xml_parse.

timvw: How would i parse it into an array? Thats the function i am looking for as the simplexml_load_string did this easily with the array elements named after the xml elements which was great. I have looking into using sax, with xml_parse but had some issues when the opening and closing tags where on seperate lines or where there were tags like:

Code: Select all

<itunes:category text="Information Technology"/>
Basically what i am looking for is a php4 equivalent of xml_load_string or an effective function / class that can already do this.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Post Reply