AngleSharp / AngleSharp.Js

:angel: Extends AngleSharp with a .NET-based JavaScript engine.

Home Page:https://anglesharp.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Replace Div with attribute, insert Razor section

weedkiller opened this issue · comments

Hi, this is great!! 💯 I am trying your scripting using the sample where I need to replace many items for print depending on the machine etc

can you please share a sample on can we find div with attributes? and replace the tags with a section - while keeping the same text or html - content on the inside.

find this <div class=print> <div class=machine >print stuff only </div></div> insert this with same old content -> @section print { <div class=@machine > print stuff only </div> }

  1. query and replace DIV's containing Class="Print Media"
  2. and then replace with Razor section like @section print {}

thanks

  1. Use the standard QuerySelectorAll (for help on this consult any guide for web development) and the replaceChild method.
  2. I am not sure I get your question. Razor is something different. Do you want to introduce strings here, print the serialized code and save this as a cshtml file?