[thelist] placing the pointer in a text file using PHP..

Tom Dell'Aringa pixelmech at yahoo.com
Mon Dec 30 16:16:00 CST 2002


--- Carl J Meyer <cjmeyer at npcc.net> wrote:
> I'm guessing this isn't really the best approach for your
> application,
> though.  It would be more efficient to strip the junk from the data
> before you write it to a file in the first place.  Or if you don't
> have
> control over how the file is written,

I don't, the header info is written to the file without me be able to
change it.

> then just strip the junk when
> you
> read it in before you do any further processing of the data, but
> don't
> bother re-writing to the file.

Here is my code that reads in the file: (w/o the associated
functions)
-------------
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen("http://www.silverheaven.com/reg/dump.xml", "r")
	or die("Error reading data.");
while ($data = fread($fp, 4096))
	xml_parse($xml_parser, $data, feof($fp))
		or die(sprintf("XML error: %s at line %d",
			xml_error_string(xml_get_error_code($xml_parser)),
			xml_get_current_line_number($xml_parser)));
fclose($fp);
xml_parser_free($xml_parser);
----------

so $fp = fopen("http://www.silverheaven.com/reg/dump.xml", "r") is
where I pull the file in - so you are saying I would strip the info
here...that makes sense. What would be the best method to do that?
That would be great if I could pull it at this point, then when it
hits the while loop, the file will be valid xml and I will have no
problem.

Tom

=====
var me = tom.pixelmech.webDeveloper();

http://www.pixelmech.com/
http://www.maccaws.com/
[Making A Commercial Case for Adopting Web Standards]

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



More information about the thelist mailing list