lov2code
lov2code

Reputation: 394

getting html tags from xml and echoing in php?

I am trying to echo a result from xml into my html code form expedia. But I ran into a problem. There text is a little messed up:

<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>

And I echo it in php:

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

And of course I get this in the browser window:

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

etc.

How can I fix this??? Any help would be greatly apreciated! Thanks! I want it to output normal text without any html tags.

Upvotes: 1

Views: 737

Answers (2)

hakre
hakre

Reputation: 197544

You are looking to decode the htmlspecialchars encoding found in that string:

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

See htmlspecialchars_decode.

Upvotes: 2

Daniel Voina
Daniel Voina

Reputation: 3215

I think that you have to use a XSL transformation of the XML.

See http://php.net/manual/en/book.xsl.php for details.

Upvotes: 0

Related Questions