我需要格式化来自xml
的html标签例如
<p><b>Location. </b> <br />Located in central Chennai, The Raintree Hotel,
Anna Salai is connected to the airport and close to U. S. Consulate,
Valluvar Kottam, and Anna University.<p><b>Hotel features</b>
Other points of interest near this luxury hotel include SDAT Tennis Stadium and Kapalishvara Temple. </p><p><b>Hotel Features. </b><br />Dining options at The Raintree Hotel, Anna Salai include 2 restaurants. A swim-up bar and a bar/lounge are open for drinks. <p>
当我使用simpleXML php从xml获取此数据时,它显示了这种类型的数据。我不想要这个原始数据。我需要这样的数据
Location
Located in central Chennai, The Raintree Hotel, Anna Salai is connected to the airport and close to U. S. Consulate, Valluvar Kottam, and Anna University. Other points of interest near this luxury hotel include SDAT Tennis Stadium and Kapalishvara Temple.
Hotel Features
Dining options at The Raintree Hotel, Anna Salai include 2 restaurants. A swim-up bar and a bar/lounge are open for drinks. Room service is available 24 hours a day. The hotel serves a complimentary breakfast. Recreational amenities include an outdoor pool, a
我需要在浏览器中显示html格式的数据而不是html标签
提前致谢
答案 0 :(得分:0)
您可以使用html-entity-decode ,如果您正在控制html的呈现方式。如果没有,您就会面临Cross-site scripting次攻击。
您可以通过将xml格式更改为不需要html标记(即包含<location>
和<description>
标记或类似标记来解决此问题。如果您从外部方获取html,请尝试自己编写解析器以安全地提取所需的部分。
答案 1 :(得分:0)
将xml的值分配给目标元素的innerHTML
属性。多数民众赞成...希望这有助于你...