Page 1 of 1

getting data from files

Posted: Fri Aug 22, 2003 8:40 am
by yaron
Hello all,
my program goal is to get info from text files and store it in db (mysql)
my input (the text file) is build like an xml file with tags.
a lot of line which looks like that.

<tagName name="parameterName" value="value" status="status" bla bla>

I need to write a script that will go line by line and first identify that the line is relevant (looks like I wrote)
then I have to get only the parameterName the value and the status (for storing).
So once I read the line I need to isolate this three elements.

I know how to open the file and read from it but can get the infromation I want. which functions can help me?
I hope the Q is understood
Thanks

Posted: Fri Aug 22, 2003 9:05 am
by will
if is it formatted like XML, why not just use an XML parser? there are plenty out there. if that is not suitable for whatever reason, let us know and we can get you pointed in the right direction.

Posted: Fri Aug 22, 2003 9:11 am
by BigE
If you want to parse out XML then you will probably want PHP's XML functions found at http://php.net/xml As for checking if you wrote them, that would be your job in your code. Also, please don't double post your question. Thanks.

can you tell me a bit more...

Posted: Fri Aug 22, 2003 9:12 am
by yaron
about xml parser? I never used xml and I'm quite new at php (wrote till now in asp).
I'm trying to use preg_match but the regular expression is a bit complex.
I knew I could probabley use xml but I never used it before...
An example with a short explanation would be just great.
Thanks