> > If I send just a line of simple text (like "The quick brown fox
> > drowned") for XML parsing, why doesn't it call the function which I
> > declare for character data handling? It doesn't even give me an error
> > :-( Is it wrong to have plain text as input for XML parsing?
> Why, as a matter of fact, yes!
> The data going into the parser needs to be valid, well-formed, XML.  I
> assume you didn't get an error message because you didn't ask to see the
> error message.  The most basic thing you can do is (assuming you've
> already declared your XML Parser functions...
>    $Contents = '<BLAH>The quick brown fox drowned</BLAH>';
>    if ( xml_parse($Parser, $Contents) ) {
>       echo "Yipee!\n";
>    } else {
>       echo "Rejected by parser:\n";
>       echo xml_error_string(xml_get_error_code($Parser));
>    }

Well, as a matter of fact I do. My code is pretty straightforward. I declare the 
        printError("failed to create xml parser");
if(!xml_set_element_handler($xml_parser, "startElementHandler", "endElementHandler")){
        printError("failed to set element handlers");
        printError("failed to set character data handler");

And then I parse looking out for any errors:
if (!xml_parse($xml_parser, $xmlstring)){
                return false;

I don't get any error. I get the $xmlstring from a database and I have verified that 
I'm getting the 1-line pure text ("the quick brown fox chocked") just fine. But when 
parsed, a call to charDataHandler() is never made :-(
Is it a bug or am I missing something obvious? Dan, did you actually run this and got 
an error?


PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to