You are here: Re: [PHP] PHP Bug/Error with XML Parsing Syntax?? « PHP « IT news, forums, messages
Re: [PHP] PHP Bug/Error with XML Parsing Syntax??

Posted by "Scott Fletcher" on 06/14/05 00:28

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@l-i-e.com> wrote in message
news:51500.67.184.124.249.1118697259.squirrel@www.l-i-e.com...
> 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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация