Home > Backend Development > PHP Tutorial > 从数据库中提取的带有HTML标签的数据经过XML传输后HTML标签消失了,如何保存用XML传输并且保存带有HTML标签的数据?

从数据库中提取的带有HTML标签的数据经过XML传输后HTML标签消失了,如何保存用XML传输并且保存带有HTML标签的数据?

WBOY
Release: 2016-06-06 20:29:11
Original
1279 people have browsed it

$query=mysql_query("SELECT text from opus where id=$id",$dbconn);

<code>while($row=  mysql_fetch_array($query)){
    $text3=$row['text'];
    $text4=html_entity_decode($text3);
    echo $text4;
}</code>
Copy after login
Copy after login

如上面这样 直接echo $text是OK的

但是像下边这样用XML返回到前端页面格式就变了

<code>echo "<?xml version='1.0' encoding='UTF-8'?>";
echo "<response>";
echo "<msg>";
echo "<text>$text4</text>";
echo "<id>$id</id>";
echo "</msg>";
echo "</response>";

求解~~</code>
Copy after login
Copy after login

回复内容:

$query=mysql_query("SELECT text from opus where id=$id",$dbconn);

<code>while($row=  mysql_fetch_array($query)){
    $text3=$row['text'];
    $text4=html_entity_decode($text3);
    echo $text4;
}</code>
Copy after login
Copy after login

如上面这样 直接echo $text是OK的

但是像下边这样用XML返回到前端页面格式就变了

<code>echo "<?xml version='1.0' encoding='UTF-8'?>";
echo "<response>";
echo "<msg>";
echo "<text>$text4</text>";
echo "<id>$id</id>";
echo "</msg>";
echo "</response>";

求解~~</code>
Copy after login
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template