[英]retrieve xml tags from sql table with php
我试图从表中检索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"];
}
打印没有标签,但我想按原样打印(带有标签)。
请帮我!
这是因为浏览器认为<product>
是HTML标记,而不显示它。 您需要像这样使用htmlentities() :
$q2 = mysql_query("SELECT * from products");
while ($rowq2 = mysql_fetch_array($q2)) {
echo htmlentities($rowq2["product_xml"]);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.