Created
          November 7, 2023 14:42 
        
      - 
      
 - 
        
Save lylejantzi3rd/e7861052c5231e2e440e95729d19bcaa to your computer and use it in GitHub Desktop.  
    Javascript XPath example
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function getElementByXpath(path) { | |
| return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; | |
| } | |
| getElementByXpath("//span[contains (text(), 'Ad')]//ancestor::article").remove() | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment