mesh2005 Posted August 27, 2007 Share Posted August 27, 2007 I'm writing a PHP script to query a database table and return the result as XML. If the result contain the letter '&', the XML is corrupted. How can I fix this problem? <xml> <record id='2' text='jjjj&kkkk'>any</record> </xml> Link to comment https://forums.phpfreaks.com/topic/66847-php-returns-invalid-xml-because-of/ Share on other sites More sharing options...
matthewhaworth Posted August 27, 2007 Share Posted August 27, 2007 http://uk2.php.net/manual/en/function.htmlspecialchars.php That'll help. Edit: no it won't lol. Link to comment https://forums.phpfreaks.com/topic/66847-php-returns-invalid-xml-because-of/#findComment-335106 Share on other sites More sharing options...
Barand Posted August 27, 2007 Share Posted August 27, 2007 Also I'd advise against storing data values as attributes <record> <id>2</id> <text>jjjj&kkkk</text> <other>any</other> </record> Use attributes for metadata (describing the data) eg <record> <id>2</id> <text>jjjj&kkkk</text> <other>any</other> <phone loc="home">888-777-6666</phone> <phone loc="office">888-666-5555</phone> </record> my $0.02 Link to comment https://forums.phpfreaks.com/topic/66847-php-returns-invalid-xml-because-of/#findComment-335110 Share on other sites More sharing options...
mesh2005 Posted August 27, 2007 Author Share Posted August 27, 2007 Thank you guys for all your help Link to comment https://forums.phpfreaks.com/topic/66847-php-returns-invalid-xml-because-of/#findComment-335212 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.