Komikio Posted June 20, 2006 Share Posted June 20, 2006 Hi there,I'm using PHP 5 and the simplexml. I have some XML file with a tag <description>, for example: <description>Hello <br>world</description> However, when I load the xml-file with simplexml it automatically replaces the <br> with <br>. This is not what I want, since my goal is to insert the data into a MySQL database (& in a field gives an unterminated entity reference error in MySQL). Now I have to manually replace the '<', '>' and '&' again with < etc.Is there a way to circumvent this and let simplexml read > as > and not as '>' so I can directly insert it into the database?Thanks! Link to comment Share on other sites More sharing options...
justsomeguy Posted June 20, 2006 Share Posted June 20, 2006 I've never used simplexml, but if you can get the contents of the description tag in a string, before you insert it into the database you can use htmlentities to convert all applicable characters:http://www.php.net/manual/en/function.htmlentities.php Link to comment Share on other sites More sharing options...
Komikio Posted June 21, 2006 Author Share Posted June 21, 2006 Some searching already brought me to htmlentities but thanks. Too bad it seems that it cannot be done in one step. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now