Advertisement
dereksir

Untitled

Nov 28th, 2023 (edited)
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.46 KB | None | 0 0
  1. //..
  2.         // Specify the inner text
  3.         string targetInnerText = "Example Text";
  4.  
  5.         // Query for the element with the specified inner text
  6.         var targetElement = document.QuerySelector($"*:contains('{targetInnerText}')");
  7.  
  8.         // Checking if the element was found
  9.         if (targetElement != null)
  10.         {
  11.             var elementText = targetElement.TextContent ?? "Not available";
  12.             Console.WriteLine(elementText);
  13.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement