[thelist] php regexp help (or some other solution maybe..)

Tom Dell'Aringa pixelmech at yahoo.com
Tue Dec 31 14:55:01 CST 2002

--- Kelly Hallman <khallman at wrack.org> wrote:

> <?php
> $fname = "http://domain.com/pathtoxml/dump.xml";
> list($head,$body) =
>     preg_split("/(?=<\?xml)/m", join("",file($fname)), 2);
> xml_parse($xmlparser,$body,1);
> ?>

I see, just use dump.xml as a temp file, run the list on it and grab
$body - makes perfect sense.

I changed my xml_parse line from:
$fp = fopen("http://www.silverheaven.com/reg/dump.xml", "r+")
xml_parse($xml_parser, $data, feof($fp))



and removed the fopen() stuff. Printing out $body looks like the
regexp worked perfectly. It seems to work until I get this error:

Warning: Supplied argument is not a valid XML Parser resource in
/post3.php on line 122
XML error: at line 1

that line is xml_parse($xmlparser,$body,1) - I assume its talking
about the optional true (1) statement, the 3rd parameter, since my
parser is there and $body seems fine. Here is my total parser code:
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");

//print $body; <-- printed out and looks fine
while($body) <-- not sure if this is right either...
   xml_parse($xmlparser, $body, 1)
      or die(sprintf("XML error: %s at line %d",

Man I'm so close I can taste it! What is this error!??


var me = tom.pixelmech.webDeveloper();

[Making A Commercial Case for Adopting Web Standards]

Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.

More information about the thelist mailing list