<html><table>
<tr>
<td>Heading 1</td> <td>Heading 2</td> <td>Heading 3</td>
</tr>
<tr><td>value 1</td> <td>value 2</td>
<td>
<?xml version="1.0" encoding="utf-16"?>
<ArrayOfMENU_BO xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<MENU_BO>
<ID>2</ID>
<CreatedBy>0</CreatedBy>
<CreatedOn>0001-01-01T00:00:00</CreatedOn>
<ModifiedBy>0</ModifiedBy>
</MENU_BO>
</ArrayOfMENU_BO>
</td></tr>
</table></html>
在第二行的第三列中,我正在显示xml数据,但是当它在浏览器中呈现时,它并没有以这种格式显示。如何以与xml相同的格式显示它?
答案 0 :(得分:0)
您需要做两件事:
(1)使用HTML标签<pre>
(2)正如William已经提到的,您需要对实际的XML尖括号进行实体编码:使用< and > instead of < and >
HTML
<pre><?xml version="1.0"?>
<movies>
<movie id="123">
<title>Pulp Fiction</title>
<year>1994</year>
<rating>8.9</rating>
</movie>
<movie id="124">
<title>Memento</title>
<year>2000</year>
<rating>8.6</rating>
</movie>
<movie id="124">
<title>The Usual Suspects</title>
<year>2000</year>
<rating>8.6</rating>
</movie>
</movies>
</pre>
在浏览器中输出
<?xml version="1.0"?>
<movies>
<movie id="123">
<title>Pulp Fiction</title>
<year>1994</year>
<rating>8.9</rating>
</movie>
<movie id="124">
<title>Memento</title>
<year>2000</year>
<rating>8.6</rating>
</movie>
<movie id="124">
<title>The Usual Suspects</title>
<year>2000</year>
<rating>8.6</rating>
</movie>
</movies>