Grab XML doc from folder and parse with PHP
Moderator: General Moderators
Grab XML doc from folder and parse with PHP
I need to be able to use PHP to grab numerous xml documents from a folder on the server, parse them and then throw the data in a mysql database.
Can anyone point me in the right direction?
Thanks
Can anyone point me in the right direction?
Thanks
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
I likeI need to be able to use PHP to grab numerous xml documents from a folder on the server
Code: Select all
glob() and file_get_contents()Use DOM (not DOMXML that's old hat), XSTL or SAX (under XML in PHP manual).parse them
I have a useful function for getting information between 2 things
Usage:
It would return "stuff goes here" inside $stuff.
I use this in php4, since I have no fancy libraries and stuff.
Code: Select all
function find($string,$opener,$closer)
{ $part1 = explode($opener,$string);
$part2 = explode($closer,$part1[1]);
$result = $part2[0];
return $result;
}Code: Select all
$string = "<stuff>stuff goes here</stuff>";
$stuff = find($string,"<stuff>","</stuff>");I use this in php4, since I have no fancy libraries and stuff.
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
I like that. Very much.GWsux wrote:I have a useful function for getting information between 2 thingsUsage:Code: Select all
function find($string,$opener,$closer) { $part1 = explode($opener,$string); $part2 = explode($closer,$part1[1]); $result = $part2[0]; return $result; }It would return "stuff goes here" inside $stuff.Code: Select all
$string = "<stuff>stuff goes here</stuff>"; $stuff = find($string,"<stuff>","</stuff>");
I use this in php4, since I have no fancy libraries and stuff.
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK