xml_parse and xml entities

From: Date: Thu, 12 Dec 2002 22:02:03 +0000
Subject: xml_parse and xml entities
Groups: php.general 
Request: Send a blank email to php-general+get-128084@lists.php.net to get a copy of this message
Hi all, I'm writing a guestbook and message in the guestbook might contain & < > so to make sure this wasn't a problem I was advised to great entities in my xml file like so <!DOCTYPE guestbook [ <!ELEMENT message (name, email, date, text)> <!ATTLIST message id CDATA #REQUIRED> <!ELEMENT name (#PCDATA)> <!ELEMENT email (#PCDATA)> <!ELEMENT date (#PCDATA)> <!ELEMENT text (#PCDATA)> <!ENTITY lt "&#38;#60;"> <!ENTITY gt "&#38;#62;"> <!ENTITY amp "&#38;#38;"> ]> and when I write to my xml file if I convert all & < > characters to &amp; &lt; &gt; problem solved. I'm having trouble though. My guestbook works fine until you enter a < > & character. This will get written to the xml file, writes fine, I can view the file in a text editor and it looks good. Parse the file back in and say the field contained... Hello Russ & Jim the parser would only hold... Jim when it writes to the array I parse into. Another example... Hello Jim Russ & becomes... & so basically if a field holds an entity the last element of the field (be it text after an entity or an entity itself) is the only part parsed. Makes no sense to me :( I would upload my source and xml file for you to check but they are big and ugly and you won't want to. Thanks very much Russ

« previous php.general (#128084) next »