public static void Main()
@"<p style=\'color: orangered; background-color: cyan;\'>\r\n The receipt of this email is intended to go to pavan.pabolu@takeda.com and CC pavan.pabolu@indegene.com \r\n</p>\r\n<p id=\'zipnotfound\' style=\'color:orangered;background-color:yellow;DISPLAY:NONE;\'>\r\n We not able found '55555' zip code, please find request to be check these details with responsible person.\r\n</p>\r\n<p>\r\n A physician has submitted a Follow-up request through the oncology MedInfo website.\r\n The health care professional’s Follow-up Inquiry and contact information appears below.\r\n</p>\r\n<p>\r\n Name: Cynthia\r\n <br />I am HCP: Yes\r\n <br />Phone Number: 1622289747\r\n <br />Email: xabo@mailinator.com\r\n <br />Profession: Nurse Practitioner\r\n <br />State: Idaho\r\n <br />ZIP Code: 55555\r\n <br />Preferred Date and Time(MM/DD/YYYY)(24hrs)(EST/EDT): 08/10/2022 10:00:00\r\n <br />Product To Be Discussed: Velcade (bortezomib)\r\n <br />Queries: Placeat esse labori\r\n <br />Contact Preference: Phone number/Request a meeting with Takeda Field Medical Affairs representative\r\n</p>\r\n<p>\r\n We appreciate your assistance in answering requests for more information about Oncology MedInfo.\r\n</p>";
var htmlDoc2 = new HtmlDocument();
htmlDoc2.LoadHtml(html2);
var nodesToRemove = htmlDoc2.DocumentNode.Descendants("p").Where(x => x.Attributes["id"] != null && x.Attributes["id"].Value == "zipnotfound").Select(x => x.XPath).ToList();
nodesToRemove.ForEach(xpath => {
var node22 = htmlDoc2.DocumentNode.SelectSingleNode(xpath);
if (node22 != null && node22.NodeType == HtmlNodeType.Element) {
Console.WriteLine(htmlDoc2.ParsedText);
<h1>This is <b>bold</b> heading</h1>
<p>This is <u>underlined</u> paragraph</p>
var htmlDoc = new HtmlDocument();
var htmlBody = htmlDoc.DocumentNode.SelectSingleNode("//body");
HtmlNode node = htmlBody.ChildNodes[1];
Console.WriteLine("\n****After removing a node from parent node****\n");
Console.WriteLine("\n****Removed node****\n");
static void DisplayNode(HtmlNode node)
Console.WriteLine("Node Name: " + node.Name);
Console.Write("\n" + node.Name + " children:\n");
static void DisplayChildNodes(HtmlNode nodeElement)
HtmlNodeCollection childNodes = nodeElement.ChildNodes;
if (childNodes.Count == 0)
Console.WriteLine(nodeElement.Name + " has no children");
foreach (var node in childNodes)
if (node.NodeType == HtmlNodeType.Element)
Console.WriteLine(node.OuterHtml);