Re: PHP Bug/Error with XML Parsing Syntax??

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Finally, the newsgroup start working once again...

The problem was
    "if (xml_error_string($xml_parser)) {"
which I was told should be
     "if (xml_get_error_code($xml_parser) != XML_ERROR_NONE) {"

It solve my problem now.

Now how do I parse the DTD's entity, element, etc along with the PHP's
"xml_parse_into_struct()"  I figured that I would need to add another
function before that to make it work.  So, can anyone give me an example
that would do the trick??

XML Code is
--snip--
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE NewsFeed [
<!ENTITY nbsp "test">
]>
<NewsFeed>
  <Message>
   Blah &nbsp;&nbsp;&nbsp;Arcadia, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TranSouth
  </Message>
</NewsFeed>
--snip--

I got
--snip--
Blah Arcadia, TransSouth
--snip--

with no "&nbsp;" within those data in the "Message" tag..

Thanks...
FletchSOD

""Richard Lynch"" <ceo@xxxxxxxxx> wrote in message
news:51500.67.184.124.249.1118697259.squirrel@xxxxxxxxxxxxxxxx
> On Mon, June 13, 2005 10:21 am, Scott Fletcher said:
> > I'm not sure what's wrong with PHP..  I ran the XML file through the
> > Mozilla
> > and it validate just fine.  I get XML parse error but it gave no reason
> > for
> > the errors.
> >
> > The source code here is
> > [code]
> > $data = "<Message>Were changing</Message>";
> >
> > $xml_parser = xml_parser_create('ISO-8859-1');
> > xml_parser_set_option($xml_parser, XML_OPTION_SKIP_WHITE, 1);
> > xml_parse_into_struct($xml_parser, trim($data), $vals, $index);
> >
> > if (xml_error_string($xml_parser)) {
> >    echo "<br>";
> >    echo "XML error in given source on <br>";
> >    echo "Line: ".xml_get_current_line_number($xml_parser)."<br>";
> >    echo "Column: ".xml_get_current_column_number($xml_parser)."<br>";
> >    echo "Reason:
> > ".xml_error_string(xml_get_error_code($xml_parser))."<br>";
> >    echo "<br>";
> >    echo "XML Data: ".$data;
> >    echo "<br>";
> > }
> >
> > xml_parser_free($xml_parser);
> > [/code]
> >
> > The Error output is ...
> >
> > [code]
> > XML error in given source on
> > Line: 1
> > Column: 32
> > Reason: <Message>Were changing</Message>
> > [/code]
> >
> > Anyone know??  I'm using PHP version 4.3.2 ....  Thanks....
>
> Wild Guess!
>
> Column 32 is the end of your data.
>
> Perhaps it wants a newline???
>
> Or, perhaps, you need something like a doctype at the beginning?
>
> -- 
> Like Music?
> http://l-i-e.com/artists.htm

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux