Finding a String Inside an XmlDocument

I need to find the inner text of an element inside an XmlDocument and return it to Xpath. for example, searching for "ThisText" inside:

<xml> <xml2>ThisText</xml2> </xml> 

should return xpath from xml2

What is the most efficient way to do this in C #?

+4
source share
1 answer

What do you think of the "xpath" element? Xpath is a query language to find node / nodes and not describe where node is located.

You can use xpath to find the given element. eg.

 xmlDocument.SelectNodes("//*[contains(text(), 'ThisText')]"); 

Then you can scroll through the returned nodes and see their name / parent, etc.

+7
source

Source: https://habr.com/ru/post/1308781/


All Articles