MySQL Forums :: XML :: avoid character enitities in output
avoid character enitities in output
Posted by: Mary Kalinosky
Date: August 12, 2009 03:34PM
I am inserting some XML nodes into a MySQL database with the following:
$xml_text = $node->ownerDocument->saveXML($node);
$insert_sql = 'INSERT INTO sections (text) VALUES("' . mysql_real_escape_string($xml_text) . '");';
When I look at the values in the text field of the sections table via phpMyAdmin or running a query in a command prompt, everything looks fine:
<graphic xlink:href="978-1-60406-186-4c003_f003" />
Axial image at the level of the aortic valve. A well-defined, low-density polypoid lesion is appreciated on the inferior surface of the aortic valve leaflets.
When I extract this data, however, using "view source" in my browser yields the following:
<caption><p><graphic-options><graphic xlink:href="978-1-60406-186-4c003_f003"/></graphic-options><bold>(A)</bold>Axial image at the level of the aortic valve. A
well-defined, low-density polypoid lesion is appreciated on the
inferior surface of the aortic valve leaflets.</p></caption>
Here is the code I'm using to extract (all_cases_text is a view that incorporates the sections table):
$select_sql = 'SELECT * FROM all_cases_text WHERE (book_id = ' . $book_id . ' AND case_id = ' . $case_id . ') ORDER BY heading_id;';
// This is part of a while loop, utf8_encode($row['text']) gets the text I inserted above.
$next_elem = $doc->createElement( $row['node_type'], utf8_encode($row['text']) );
// Append the section element.
// Send the XML to the browser
I get the output with character entities (< >) whether I use the utf8_encode() function or not. Eventually, I need to transform the DOMDocument I'm getting with some XSLT. How do I keep the output from giving me character entities for the tag brackets? They aren't even in the database in the first place.
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.