我试图将xml的结果回显到我的html代码表单expedia中。但是我遇到了一个问题。文字有点混乱:
<areaInformation>
Distances are calculated in a straight line from the property's location to the point of interest or attraction, and may not reflect actual travel distance. <br /><br /> Distances are displayed to the nearest 0.1 mile and kilometre. <p>La Isla Shopping Mall - 0.5 km / 0.3 mi <br />Yamil Lu'um - 0.5 km / 0.3 mi <br />Acuario Interactivo - 0.6 km / 0.3 mi <br />Luxury Avenue - 1.5 km / 0.9 mi <br />Cancun Golf Club at Pok Ta Pok - 2.2 km / 1.3 mi <br />Nautilus Diving and Training Center - 2.6 km / 1.6 mi <br />Cancun Convention Center - 2.8 km / 1.7 mi <br />Plaza Caracol - 2.8 km / 1.8 mi <br />Playa Tortuga - 3.1 km / 1.9 mi <br />Aquaworld - 3.6 km / 2.2 mi <br />Playa Langosta - 4.1 km / 2.6 mi <br />Museo de Arte Popular Mexicano - 4.6 km / 2.9 mi <br />Playa Linda - 5 km / 3.1 mi <br />Playa Delfines - 6.1 km / 3.8 mi <br />El Rey Ruins - 6.2 km / 3.8 mi <br /></p><p>The preferred airport for ME Cancun - Complete ME All Inclusive is Cancun, Quintana Roo (CUN-Cancun Intl.) - 14.3 km / 8.9 mi. </p>
</areaInformation>
我在php中回应它:
<div id="hotelInfo"><?php echo $areaInfo ?></div>
当然,我在浏览器窗口中看到了这个:
Distances are calculated in a straight line from the property's location to the point of interest or attraction, and may not reflect actual travel distance. <br /><br /> Distances are displayed to the nearest 0.1 mile and kilometre. <p>La Isla Shopping Mall - 0.5 km / 0.3 mi <br />Yamil Lu'um - 0.5 km / 0.3 mi <br />Acuario Interac
等
我该如何解决这个问题?任何帮助都会受到极大的折磨!谢谢! 我希望它输出普通文本而不带任何html标签。
答案 0 :(得分:2)
您正在寻找解码该字符串中的htmlspecialchars
编码:
<div id="hotelInfo"><?php echo htmlspecialchars_decode($areaInfo) ?></div>
答案 1 :(得分:0)
我认为您必须使用XML的XSL转换。
有关详细信息,请参阅http://php.net/manual/en/book.xsl.php。