Page 1 of 1

need help with parsing xml file

Posted: Tue Aug 26, 2003 8:21 am
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

Posted: Tue Aug 26, 2003 9:32 pm
by BDKR

Posted: Wed Aug 27, 2003 9:36 am
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

Posted: Wed Aug 27, 2003 11:17 am
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