Hi there,

This is not a bug.. this is expected behaviour.

The string would be chopped up into 3 parts because you have :

1. a string: "Follow-up To Critique of BeOS "
2. a predefined entity : "&"
3. a string: "amp; Mac OS X"

There are not actually two ampersands.. you have & followed by amp; -
this is so that once it has been parsed you end up with & which will
display correctly in most HTML browsers.

Note that & is a usually a predefined entity in XML and so will be
replaced with "&".

HTH

Matt.

-----Original Message-----
From: Ben Gollmer [mailto:[EMAIL PROTECTED]]
Sent: 01 January 2002 00:23
To: [EMAIL PROTECTED]
Subject: [PHP] XML Parsing Problem


Hi all -

I'm experimenting with PHP's XML parser for an application that maps XML
tags to MySQL database fields.

As a test for my parsing program, I've been grabbing XML from the
Slashdot news feed (http://www.slashdot.org/slashdot.xml) and inserting
it into a database. This is very simple data - <title>blah</title> gets
inserted into the 'title' field, etc. However, when there are some
strange characters in the title field, the XML parser seems to choke.

Here is an example. The title of a recent article from Slashdot looks
like this in the XML file:

<title>Follow-up To Critique of BeOS &amp;amp; Mac OS X</title>

Don't ask my why they have a double ampersand in there... Anyway, the
XML parser returns this as three sets of data, instead of one. The array
that I get looks like this:

$myArray[0] = "Follow-up To Critique of BeOS "
$myArray[1] = "&"
$myArray[2] = "amp; Mac OS X"

This is the data I get back from the parser, BEFORE putting it into the
database. I'm echoing each array field to the screen, just to make sure.
So I know it has nothing to do with MySQL. The double ampersand
shouldn't make a difference - the XML parser should not be interpreting
HTML...right? Also, I don't get an error code or error string from
xml_parse().

Anyone have any ideas? This is a subtle bug - in fact I had been
satisfied with my XML parsing code, and was well into the rest of my
application when I happened to notice this.

Ben


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to