MySQL Forums
Forum List  »  Connector/Node.js

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:

<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>


When I extract this data, however, using "view source" in my browser yields the following:

&lt;caption&gt;&lt;p&gt;&lt;graphic-options&gt;&lt;graphic xlink:href="978-1-60406-186-4c003_f003"/&gt;&lt;/graphic-options&gt;&lt;bold&gt;(A)&lt;/bold&gt;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.&lt;/p&gt;&lt;/caption&gt;


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']) );
$section_elem->appendChild($next_elem);

// Append the section element.
$case_dom->appendChild($section_elem);

// Send the XML to the browser
print($case_dom->saveXML());

I get the output with character entities (&lt; &gt;) 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.

Options: ReplyQuote


Subject
Written By
Posted
avoid character enitities in output
August 12, 2009 03:34PM


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.