2016-03-03 4 views
0

Я создаю xml-файл, который вытащит описание продукта (opencart). Проблема в том, что он отображает весь html внутри описания. Я хочу, чтобы получить простой текст без каких-либо HTML-теги, дивы, стили и т.д.Получить текст из строки html

Например жала выводит ниже HTML в XML

<p><span style="font-weight: bold; font-family: Arial; color: rgb(0, 0, 0); font-size: 18px; font-style: italic;">Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed</span></p> 
 

 
<p><span style="font-family: Arial; font-size: 14px; color: rgb(0, 0, 0);">diam nonummy nibh euismod tincidunt ut laoreet dolore magna.</span></p> 
 

 
<p><span style="font-family: Arial; font-size: 14px; color: rgb(0, 0, 0);">aliquam erat volutpat. Ut wisi enim ad minim veniam, quis</span></p> 
 

 
<p><span style="font-family: Arial; font-size: 14px; color: rgb(0, 0, 0);">nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip&nbsp;</span><span style="color: rgb(0, 0, 0); font-family: Arial; font-size: 14px;">nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip.</span><span style="color: rgb(0, 0, 0); font-family: Arial; font-size: 14px;">nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip</span><span style="color: rgb(0, 0, 0); font-family: Arial; font-size: 14px;">&nbsp;nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip</span><span style="color: rgb(0, 0, 0); font-family: Arial; font-size: 14px;">nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip.</span><span style="color: rgb(0, 0, 0); font-family: Arial; font-size: 14px;">nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip</span></p> 
 

 
<p><span style="font-family: Arial; font-size: 14px; color: rgb(0, 0, 0);">&nbsp;</span></p> 
 

 
<p><span style="font-family: Arial; color: rgb(0, 0, 0); font-size: 18px; font-weight: bold;">nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip</span></p> 
 

 
<ul> 
 
\t <li><span style="font-family: Arial; font-size: 14px; color: rgb(0, 0, 0);">nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip</span></li> 
 
\t <li><span style="font-family: Arial; font-size: 14px; color: rgb(0, 0, 0);">nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip</span></li> 
 
\t <li><span style="font-family: Arial; font-size: 14px; color: rgb(0, 0, 0);">nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip</span></li> 
 
\t <li><span style="font-family: Arial; font-size: 14px; color: rgb(0, 0, 0);">nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip</span></li> 
 
\t <li><span style="font-family: Arial; font-size: 14px; color: rgb(0, 0, 0);">nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip</span></li> 
 
</ul> 
 

 
<p><em><strong><span style="font-family: Arial; font-size: 14px; color: rgb(0, 0, 0);">nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip</span></strong></em></p> 
 

 
<p><span style="font-family: Arial;">&nbsp;</span></p> 
 

 
<p>&nbsp;</p>

на $ продукта [ 'description'], и я хочу оставить только описание без тэгов html.

Я попытался

$ ProdDescr = strip_tags (html_entity_decode ($ произведение [ 'описание'], ENT_QUOTES, 'UTF-8'));

, но это дает мне ошибки в XML

Я также попытался

$ ProdDescr = strip_tags ($ продукта [ 'описание']; EHCO $ ProdDescr;

а также не повезло

Можете ли вы рассказать мне, как сохранить только те xt строки? Thanks

ответ

0
<![CDATA['.strip_tags(htmlspecialchars_decode($product['description'])).']] 
Смежные вопросы