T
T
Think With Your Head2015-06-23 13:36:43
HTML
Think With Your Head, 2015-06-23 13:36:43

How to clear the html table obtained from excel from garbage?

You need to remove classes, inline styles, tag attributes.
Leave only content + hyperlinks.
I tried online tools - those that were more or less suitable for some reason removed links along with the garbage, but I need them

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
entermix, 2015-06-23
@Vyad

Remove everything unnecessary with regular expressions for example

D
Dmitry Evgrafovich, 2015-06-23
@Tantacula

www.artlebedev.ru/tools/reformator

T
Think With Your Head, 2015-06-23
@Vyad

Thank you all for participating! Understood:

<?php
    $content = file_get_contents('table.html');

    $table = preg_replace("/<([a-z][a-z0-9]*)(?:[^>]*(\shref=['\"][^'\"]*['\"]))?[^>]*?(\/?)>/i",'<$1$2$3>', $content);
?>
<body>
    <?=$table?>
</body>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question