using HtmlAgilityPack; var html = @"This is my contentThis is another content"; var doc = new HtmlDocument(); doc.LoadHtml(html); var nodes = doc.DocumentNode.Descendants().Where(n => n.Attributes["class"]?.Value == "my-class").ToList(); foreach (var node in nodes) { Console.WriteLine(node.InnerHtml); }
using System.Xml; var xmlDoc = new XmlDocument(); xmlDoc.Load("path/to/xml/file"); var nodes = xmlDoc.GetElementsByTagName("item"); foreach (XmlNode node in nodes) { Console.WriteLine(node.InnerXml); }This example demonstrates how to retrieve the inner HTML of all XML nodes with tag name "item" in an XML file. This example doesn't require a package library as it uses built-in .NET framework classes.