PHP에서 xml 콘텐츠를 표시 한 후 html 태그를 제거하는 방법은 무엇입니까? 나는 또한 strip_tags
을 시도했지만 HTML 태그를 제거하기 위해 노력하고 있지 않습니까? PHP 페이지PHP에서 xml 콘텐츠를 표시 한 후 html 태그를 제거하는 방법?
<div style="width:50%" align="center"> <?php echo strip_tags($a) ?></div>
** aboutus.xml 파일 **
<?xml version="1.0" encoding="UTF-8"?>
<item><pubDate>Sat, 05 Oct 2013 14:43:39 +0500</pubDate>
<title><![CDATA[Who We Are]]></title>
<url><![CDATA[about-us]]></url>
<meta><![CDATA[]]></meta>
<metad><![CDATA[]]></metad>
<menu><![CDATA[About Us]]></menu>
<menuOrder><![CDATA[0]]></menuOrder>
<menuStatus><![CDATA[]]></menuStatus>
<template><![CDATA[template.php]]></template>
<parent><![CDATA[]]></parent>
<content>
<![CDATA[<h1>Who We Are</h1><p>&nbsp;</p>
<h2>About Desk</h2>
<p>&nbsp;</p>
<p><span style=\"text-align: justify;\">
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry\'s standard dummy text ever since
the 1500s, when an unknown printer took a galley of type and scrambled
it to make a type specimen book. It has survived not only five centuries,
but also the leap into electronic typesetting, remaining essentially unchanged.
It was popularised in the 1960s with the release of Letraset sheets containing
Lorem Ipsum passages, and more recently with desktop publishing software
PageMaker including versions of Lorem Ipsum.</span></p>
]]>
</content>
</item>
표시 내용에
는PHP 코드
<?php
$doc = new DOMDocument();
$doc->load('aboutus.xml');
$items = $doc->getElementsByTagName("item");
foreach($items as $item)
{
$contents = $item->getElementsByTagName("content");
$content = $contents->item(0)->nodeValue;
$a= $content;
}
?>
디스플레이 XML 내용 스크린 샷
솔루션
<?php echo strip_tags(html_entity_decode($a)) ?>
코드는 참조 작동합니다 : https://eval.in/96248은' 즉해야 할 수도 있습니다, 그래서', 인코딩 된 더블 추가 str_replace. – ThW