How to use xpath in C# code to remove multiple html elements with specific words inside?

Maroso

Client
Регистрация
31.07.2013
Сообщения
23
Благодарностей
2
Баллы
3
I get DOM result from wabpage/url to variable, from there I clean it a little bit with regex where I can and keep only the <body> </body> part.
From there I have a txt file with different words (aside, sidebar, widget, login, register), over 50 words in total, and I just want to check html tags if they contain this words, in any order, case insensitive and can be grouped with other words, for example when looking after “sidebar” to match words like “foosidebar” OR “sidebarfoo” or “foosidebarfoo” .

For example, let say that txt file with words to look after contain “aside, sidebar, widget, login, register “ and the html from variable to analyze is:
<p class='my class'>This is some text</p>
<h1 class='btn sidebar btn-now'><p>We have more text here</p><p> and anoter text here</p></div>
<div id='something here'>New text here</div>
<div id='something sidebar here'>New text again</div>
<nav class='this sidebar btn'>This is my nav</nav>
<aside><div>This is some text</div></aside>
<aside><div>Again new text</div></aside>

I want to remove this html tags:
<h1 class='btn sidebar btn-now'><p>We have more text here</p><p> and another text here</p></div>
<div id='something sidebar here'>New text again</div>
<nav class='this sidebar btn'>This is my nav</nav>
<aside><div>This is some text</div></aside>
<aside><div>Again new text</div></aside>

Html tags that should remain are:
<p class='my class'>This is some text</p>
<div id='something here'>New text here</div>

The xpath that I think should work is:
//*[contains(@*, "sidebar") or contains(name(), "sidebar")]

Can anyone here help me out with the c# code part to solve it. I’m also ok to pay for the code if that makes it happening
Any suggestion?
 

Maroso

Client
Регистрация
31.07.2013
Сообщения
23
Благодарностей
2
Баллы
3
Someone, any suggestion?
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)