need help with parsing xml file

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
yaron
Forum Contributor
Posts: 157
Joined: Fri Aug 22, 2003 8:40 am

need help with parsing xml file

Post by yaron »

Hello all.
my input is xml files and I understand that the easiest way to get this data is by parsing it.
I'm new in xml and I have no idea how to parse my data.
can anyone please explain me the basics?
Thanks
Yaron
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

parsing is using regular expressions.

http://www.php.net

i suggest using the perl ones since it has non-greedy abilities.

so.....

http://us3.php.net/manual-lookup.php?pattern=preg

is probably the page you want.

incase you don't know perl, but do know regex, the following are the perl shorts:
\w=[A-Za-z0-9_]
\W= not \w
\d=[0-9]
\D= not \d
\s=[\f\n\t\r ]
\S= not \s
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

m3rajk wrote:parsing is using regular expressions.

http://www.php.net

i suggest using the perl ones since it has non-greedy abilities.

so.....

http://us3.php.net/manual-lookup.php?pattern=preg

is probably the page you want.

incase you don't know perl, but do know regex, the following are the perl shorts:
\w=[A-Za-z0-9_]
\W= not \w
\d=[0-9]
\D= not \d
\s=[\f\n\t\r ]
\S= not \s
Now I'm not a big XML guy, but I'm pretty sure that you don't need reg-ex to parse XML. Unless you build your own XML parser in PHP, but why do that? There are a good number of allready written XML parsers classes for PHP out there. I don't think they're using it either.

Correct me if I'm wrong about this, but we just don't want to steer the poor chap in the wrong direction do we?

Otherwise, I'd say you're on track. However I'll also add that some of the builtin functions like string replace as an example are faster than their preg equivalents.

Cheers,
BDKR
Post Reply