HtmlParsingHelper.TryExtractTagContent Method

Namespace
Kampute.DocToolkit.Support
Assembly
  • Kampute.DocToolkit.dll

Definition

Attempts to extract the content between opening and closing tags with the specified name.
public static bool TryExtractTagContent(string html, string tagName, [NotNullWhen(true)] out string content)

Parameters

html string
The HTML content to search.
tagName string
The name of the tag to search for.
content string
When this method returns, contains the content between the tags, if found; otherwise, null. This parameter is passed uninitialized.

Returns

bool
true if the content was successfully extracted; otherwise, false.

Remarks

The content is taken from the first opening tag up to its matching closing tag, so nested elements with the same tag name are part of the content. Tag-like text in comments, quoted attributes, and raw text elements is not treated as markup.