Re: xml_parse and xml entities

From: Date: Fri, 13 Dec 2002 01:21:02 +0000
Subject: Re: xml_parse and xml entities
Groups: php.general 
Request: Send a blank email to php-general+get-128104@lists.php.net to get a copy of this message
hi Russ, why don't you just str_replace the <, > and & with their entities and when they get extracted the parser will normally replace them with their original form, won't it? Regards, Khalid Al-Kary
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     "&#60;">
 <!ENTITY gt     "&#62;">
 <!ENTITY amp    "&#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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
_________________________________________________________________ MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus

« previous php.general (#128104) next »