Christopher M. Jones on 17 Aug 2006 19:13:59 -0000 |
I'm writing a web app that needs to import data from an sgml file, interpret the fields, and put the data into a mysql database. The app is php, and I thought I could do this using php file handling functions. The problem is that php seems to strip out the tags when it opens the file. The file consists of entries formated like this (this is a qfx file, in case anybody recognizes it): <STMTTRN> <TRNTYPE>DIRECTDEBIT <DTPOSTED>20060612160000 <TRNAMT>-0000000000150.00 <FITID>2006061201 <REFNUM>9500000000 <NAME>CAPITAL ONE CARD ONLINE PMT <MEMO>ONLINE PMT </STMTTRN> I expected to be able to loop through it with something like this: <?php $handle = fopen("./export.qfx", "rb"); while(!feof($handle)){ $read = fgets($handle); echo $read."</br>"; } fclose($handle); ?> But the output looks like this: DIRECTDEBIT 20060612160000 -0000000000150.00 2006061201 9500000000 CAPITAL ONE CARD ONLINE PMT ONLINE PMT No tags. And if I try to put conditionals in the loop to let me know when it has the beginning of an entry, marked by <STMTTRN> ... </STMTTRN>, it won't find anything. For example, this . . . <?php $handle = fopen("./export.qfx", "rb"); while(!feof($handle)){ $read = fgets($handle); if(ereg("<STRTTRN>", $read)){ echo "Entry marked</br>"; } } fclose($handle); ?> . . . brings up an empty page. Do I need to use different functions? I've tried several of the various file opening, reading, and printing functions I could find in the php function references, but nothing worked. Am I doing something wrong? ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug
|
|