using System.Collections.Generic;
string htmlString = "<p class=\"CaselawCoversheet DocDefaults \"><span class=\"DefaultParagraphFont \" style=\"font-style: italic;;font-family: 'Arial';white-space:pre-wrap;\">- Re </span><span class=\"DefaultParagraphFont \" style=\"font-style: italic;;font-family: 'Arial';\">ELMO Software Ltd (No 2)</span><span class=\"DefaultParagraphFont \" style=\"font-style: italic;;font-family: 'Arial';white-space:pre-wrap;\"> </span><span style=\"font-family: 'Arial';\">[2023] NSWSC 81</span><span class=\"DefaultParagraphFont \" style=\"font-style: italic;;font-family: 'Arial';white-space:pre-wrap;\"> </span></p>\r\n\r\n<p class=\"CaselawCoversheet DocDefaults \"><span class=\"DefaultParagraphFont \" style=\"font-style: italic;;font-family: 'Arial';white-space:pre-wrap;\">- </span><span class=\"DefaultParagraphFont \" style=\"font-style: italic;;font-family: 'Arial';\">Re</span><span class=\"DefaultParagraphFont \" style=\"font-style: italic;\"><span style=\"font-family: 'Arial';white-space:pre-wrap;\"> InvoCare Ltd</span></span><span class=\"DefaultParagraphFont \" style=\"font-style: italic;;font-family: 'Arial';white-space:pre-wrap;\"> </span><span style=\"font-family: 'Arial';\">[2023] NSWSC 1180</span></p>\r\n\r\n<p class=\"CaselawCoversheet DocDefaults \"><span style=\"font-family: 'Arial';white-space:pre-wrap;\">- </span><span class=\"DefaultParagraphFont \" style=\"font-style: italic;;font-family: 'Arial';\">Re Pendal Group Ltd (No 3)</span><span style=\"font-family: 'Arial';white-space:pre-wrap;\"> [2023] NSWSC 14</span></p>\r\n\r\n<p class=\"CaselawCoversheet DocDefaults \"><span class=\"DefaultParagraphFont \" style=\"font-style: italic;;font-family: 'Arial';white-space:pre-wrap;\">- </span><span class=\"DefaultParagraphFont \" style=\"font-style: italic;;font-family: 'Arial';\">Re Permanent Trustee Co Ltd</span><span style=\"font-family: 'Arial';white-space:pre-wrap;\"> (2002) 43 ACSR 601 </span></p>\r\n\r\n<p class=\"CaselawCoversheet DocDefaults \"><span class=\"DefaultParagraphFont \" style=\"font-style: italic;;font-family: 'Arial';white-space:pre-wrap;\">- </span><span class=\"DefaultParagraphFont \" style=\"font-style: italic;;font-family: 'Arial';\">Re Seven Network Ltd (No 3)</span><span style=\"font-family: 'Arial';white-space:pre-wrap;\"> (2010) 267 ALR 583</span></p>\r\n\r\n<p class=\"CaselawCoversheet DocDefaults \"><span style=\"font-family: 'Arial';white-space:pre-wrap;\">- </span><span class=\"DefaultParagraphFont \" style=\"font-style: italic;;font-family: 'Arial';\">Re Staging Connections Group Ltd (No 2)</span><span style=\"font-family: 'Arial';white-space:pre-wrap;\"> [2015] FCA 1102</span></p>";
string jsonString = ExtractTextAsJson(htmlString);
Console.WriteLine(jsonString);
static string ExtractTextAsJson(string html)
List<string> textList = new List<string>();
HtmlDocument doc = new HtmlDocument();
var textNodes = doc.DocumentNode.SelectNodes("//p[(contains(@class,'Body') or contains(@class,'CaselawCoversheet') or contains(@class,'Normal')) and contains(@class,'DocDefaults')]");
foreach (var node in textNodes)
textList.Add(node.InnerText.Trim());
string jsonString = JsonConvert.SerializeObject(textList, Formatting.Indented);