2
2
2slide2014-02-15 02:40:29
PHP
2slide, 2014-02-15 02:40:29

How to implement text parsing with tags?

Hi all!
Need your advice. Used the search. Google too. But apparently he did not learn how to find the necessary information.
I need to make something like a text parser (with html tags) from a website.
It is necessary to remove all prohibited tags and everything in between:

<div>
 содержание блока
</div>

But if the block is between the codes tags, don't delete it.
<codes lang="css">
 //код
 </codes>

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexey Firsov, 2014-02-17
@2slide

habrahabr.ru uses jevix.ru/project

I
Ilya Akulenko, 2014-02-15
@cytomich

php.net/manual/ru/function.strip-tags.php
php.net/manual/ru/function.str-replace.php

J
JRazor, 2014-02-15
@JRazor

It's strange that no one has mentioned XPath .
It 's more clear here.

J
Jonh Doe, 2014-02-16
@CodeByZen

cytomich gave the link correctly. strip-tags allows you to specify as the second parameter tags that should not be touched.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question