Page 1 of 1
XML Parsing with PHP4
Posted: Tue Apr 25, 2006 8:51 am
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?
Posted: Tue Apr 25, 2006 9:27 am
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...
Posted: Tue Apr 25, 2006 11:52 am
by timvw
parse into struct / array.. And then you can iterate over that array more or less like you'd use simplexml...
Posted: Tue Apr 25, 2006 4:22 pm
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.
Posted: Tue Apr 25, 2006 4:40 pm
by timvw