Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/264.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从xml中获取html标记并在php中进行响应?_Php_Html_Xml - Fatal编程技术网

从xml中获取html标记并在php中进行响应?

从xml中获取html标记并在php中进行响应?,php,html,xml,Php,Html,Xml,我正试图将xml的结果回显到我的html代码表单expedia中。但我遇到了一个问题。这里的文字有点混乱: <areaInformation> Distances are calculated in a straight line from the property&apos;s location to the point of interest or attraction, and may not reflect actual travel distance. &l

我正试图将xml的结果回显到我的html代码表单expedia中。但我遇到了一个问题。这里的文字有点混乱:

<areaInformation>
Distances are calculated in a straight line from the property&apos;s location to the point of interest or attraction, and may not reflect actual travel distance. &lt;br /&gt;&lt;br /&gt; Distances are displayed to the nearest 0.1 mile and kilometre. &lt;p&gt;La Isla Shopping Mall - 0.5 km / 0.3 mi &lt;br /&gt;Yamil Lu&apos;um - 0.5 km / 0.3 mi &lt;br /&gt;Acuario Interactivo - 0.6 km / 0.3 mi &lt;br /&gt;Luxury Avenue - 1.5 km / 0.9 mi &lt;br /&gt;Cancun Golf Club at Pok Ta Pok - 2.2 km / 1.3 mi &lt;br /&gt;Nautilus Diving and Training Center - 2.6 km / 1.6 mi &lt;br /&gt;Cancun Convention Center - 2.8 km / 1.7 mi &lt;br /&gt;Plaza Caracol - 2.8 km / 1.8 mi &lt;br /&gt;Playa Tortuga - 3.1 km / 1.9 mi &lt;br /&gt;Aquaworld - 3.6 km / 2.2 mi &lt;br /&gt;Playa Langosta - 4.1 km / 2.6 mi &lt;br /&gt;Museo de Arte Popular Mexicano - 4.6 km / 2.9 mi &lt;br /&gt;Playa Linda - 5 km / 3.1 mi &lt;br /&gt;Playa Delfines - 6.1 km / 3.8 mi &lt;br /&gt;El Rey Ruins - 6.2 km / 3.8 mi &lt;br /&gt;&lt;/p&gt;&lt;p&gt;The preferred airport for ME Cancun - Complete ME All Inclusive is Cancun, Quintana Roo (CUN-Cancun Intl.) - 14.3 km / 8.9 mi. &lt;/p&gt;
</areaInformation>

距离是以直线计算的,距离物业&apos;到景点或景点的位置,可能不反映实际旅行距离。br/br/距离显示为最接近的0.1英里和公里。pLa Isla购物中心-0.5公里/0.3英里br/亚米尔路&apos;um-0.5公里/0.3英里br/阿卡里奥互动-0.6公里/0.3英里br/豪华大道-1.5公里/0.9英里br/波克塔波克坎昆高尔夫俱乐部-2.2公里/1.3英里br/鹦鹉螺潜水和训练中心-2.6公里/1.6英里br/坎昆会议中心-2.8公里/1.7英里br/卡拉科尔广场-2.8公里/1.8英里br/托尔图加海滩-3.1公里/1.9英里br/水上世界-3.6公里公里/2.2英里br/兰戈斯塔海滩-4.1公里/2.6英里br/墨西哥大众艺术博物馆-4.6公里/2.9英里br/琳达海滩-5公里/3.1英里br/德尔菲内斯海滩-6.1公里/3.8英里br/埃尔雷遗址-6.2公里/3.8英里br//pp我首选的坎昆机场-包括坎昆、金塔纳罗(坎昆坎昆坎昆国际机场)-14.3公里/8.9英里/P
我用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
从酒店位置到景点或景点的直线计算距离,可能无法反映实际旅行距离

距离显示为最接近的0.1英里和公里 拉伊斯拉购物中心-0.5公里/0.3英里
亚米尔卢姆-0.5公里/0.3英里
等等

我怎样才能解决这个问题???任何帮助都将不胜感激!谢谢
我希望它输出普通文本而不带任何html标记。

我认为您必须使用XML的XSL转换


有关详细信息,请参阅。

您正在寻找对该字符串中的
htmlspecialchars
编码进行解码:

<div id="hotelInfo"><?php echo htmlspecialchars_decode($areaInfo) ?></div>


请参阅。

编辑XML文件并使用a。确切的问题是什么?你给我们输入和不好的输出,好的,但也给我们想要的输出,以帮助我们理解你的需求。我希望它输出没有任何html标记的正常文本。如何用火箭枪杀死苍蝇。我看了这个,什么都不懂。你能给我举个例子吗?@WhitneySarahRogers,正如我对Daniel所说的,XSL转换是一个强大而复杂的工具。没有必要学习和使用这种工具来解决您的小格式问题。@lorenzo-s:XSL在这里甚至不起作用,因为所讨论的字符串不是XML。所以即使它很强大,在这里也不会有任何力量;)不客气。如果您还想删除所有HTML标记,可以在解码HTML特殊字符后运行。对于所有这些基本功能,PHP已经内置了有用的功能。