我正在尝试从表中检索xml标记。 我不能打印标签,只打印值。
例如:
<product>
<item>a</item>
<price>20</price>
</product>
当我尝试使用php代码打印时:
$q2 = mysql_query("SELECT * from products");
while ($rowq2 = mysql_fetch_array($q2)) {
echo $rowq2["product_xml"];
}
打印没有标签,但我想打印它(带标签)。
请帮助我!
答案 0 :(得分:0)
这是因为浏览器认为<product>
是HTML标记并且不显示它。
你需要像这样使用htmlentities():
$q2 = mysql_query("SELECT * from products");
while ($rowq2 = mysql_fetch_array($q2)) {
echo htmlentities($rowq2["product_xml"]);
}