scinfu/SwiftSoup

How to prevent html fragment parsing from wrapping with html tags

bcardarella opened this issue · 1 comments

If I do the following:

Parser.parseFragment("<div>Hello, world!</div>", nil, "")

I get an resulting fragment with html of:

<html>
  <head></head>
  <body>
    <div>Hello, world!</div>
  </body>
</html>

whereas I want to preserve the actual fragment of just : <div>Hello, world!</div> and not wrap in additional tags. How best can I go about this?

Hi @bcardarella 👋🏻
Try to use var html = try document.body()?.html() to avoid additional tags wrapping.