getting data from files

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

getting data from files

Post 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
will
Forum Contributor
Posts: 120
Joined: Fri Jun 21, 2002 9:38 am
Location: Memphis, TN

Post 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.
User avatar
BigE
Site Admin
Posts: 139
Joined: Fri Apr 19, 2002 9:49 am
Location: Missouri, USA
Contact:

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

can you tell me a bit more...

Post 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
Post Reply