You can do it with linq
var xml = XDocument.Load(@"path", LoadOptions.SetLineInfo);
var lineNumbers = xml.Descendants()
.Where(x =>!x.Descendants().Any() && //exact node contains the value
x.Value.Contains("Acknowledgments"))
.Cast<IXmlLineInfo>()
.Select(x => x.LineNumber);
Related Contents:
- Read a XML (from a string) and get some fields – Problems reading XML
- Generate C# class from XML
- Convert XML String to Object
- Read XML Attribute using XmlDocument
- How to serialize/deserialize to `Dictionary` from custom XML not using XElement?
- Serializing private member data
- How would you compare two XML Documents?
- Why does C# XmlDocument.LoadXml(string) fail when an XML header is included?
- Format a date in XML via XSLT
- Escape invalid XML characters in C#
- xml.LoadData – Data at the root level is invalid. Line 1, position 1
- String escape into XML
- How to deal with XML in C#
- Removing nodes from an XmlDocument
- Serialize Property as Xml Attribute in Element
- How to read attribute value from XmlNode in C#?
- .net XML Serialization – Storing Reference instead of Object Copy
- How do I convert an ISO8601 TimeSpan to a C# TimeSpan?
- What is the difference between Linq to XML Descendants and Elements
- Serialize a nullable int
- how to use XPath with XDocument?
- Query an XDocument for elements by name at any depth
- How to decode string to XML string in C#
- How to prevent blank xmlns attributes in output from .NET’s XmlDocument?
- Generating XML file using XSD file
- get line number for XElement here
- How to serialize/deserialize simple classes to XML and back
- XmlSerializer – There was an error reflecting type
- Entity Framework with XML Files [closed]
- How to store data locally in .NET (C#) [closed]
- Error Deserializing Xml to Object – xmlns=” was not expected
- XML Parsing – Read a Simple XML File and Retrieve Values
- How to check for valid xml in string input before calling .LoadXml()
- Deserializing XML File with multiple element attributes – attributes are not deserializing
- How to convert XML to JSON using C#/LINQ?
- XmlTextReader vs. XDocument
- Reading large XML documents in .net
- Should ‘using’ directives be inside or outside the namespace?
- Is there any significant difference between using if/else and switch-case in C#?
- How do I get formatted JSON in .NET using C#?
- Routing with Multiple Parameters using ASP.NET MVC
- Handling warning for possible multiple enumeration of IEnumerable
- Why do C# multidimensional arrays not implement IEnumerable?
- .NET HashTable Vs Dictionary – Can the Dictionary be as fast?
- Show Loading animation during loading data in other thread
- How to convert linq results to HashSet or HashedSet
- Correlation of two arrays in C#
- How to convert date format to DD-MM-YYYY in C#
- Parse string to enum type
- How to make inline functions in C#