Xpath vs queryselector. evaluate() method to get an element by XPath.
Xpath vs queryselector Playwright comes with UI Mode , where you can easily walk through each step of the test, see logs, errors, network requests, inspect the DOM snapshot and more. querySelector样式选择器进行html解析(二):扩展一下xpath以便支持正则 使用xpath实现document. from parent to child) May 29, 2023 · To summarize XPath vs CSS selectors - both are great tools for parsing HTML though CSS selectors are briefer and easier to use while XPath is more powerful but more verbose and complex. By why use XPath when methods like querySelector and querySelectorAll work great? It’s all because of the structure of an HTML document. text 文本选择器 4. I want to select an element that has "Hello World!" literally anywhere in its code. The querySelector() method allows you to select the first element that matches one or more CSS selectors. Apr 6, 2023 · 文章浏览阅读2. Figure 4: The comparison and validation of the XPath vs querySelector for shadow DOM. 1Selector 选择器,也就是通常说的元素定位了 ,常用的有四种。 1. XPath vs. Luckily, most programming languages support both and when web scraping we're best to mix these two technologies! その場合はCSSセレクタではなくXPathのほうが便利。 ちょっとコツが要るが、「クラス名がc-paging__pagenavi-itemのテキストが">"というアンカーをクリックしなさい」というソースは以下のスニペットでいける。 Mar 23, 2023 · const xpath = "your_xpath_here"; const element = document. from child to parent), whereas cssSelector can only traverse down the DOM (e. Creating in XPath is more flexible than in CSS Selector. The main interface to using XPath is the evaluate function of the document object. Generally, more specific xpath selectors, as in the above example, usually give a significant performance improvement, especially on very large documents. XPath also offers a rich set of built-in functions and operators, enabling advanced selection and data processing tasks. evaluate() method to get an element by XPath. g. 开头的,判断为xpath. querySelector() method to fetch the element. That way you can see the minor configuration difference and see which tests effectively work in action. XPath allows you to navigate up the DOM when looking for elements to test or scrape. I want to know I can using document. Selecting via textDocument isn't good because there are many spans with the same textDocument. querySelectorAll() Returns a NodeList containing all matching Element nodes within the node's subtree, or an empty NodeList if no matches are found. For Sep 19, 2024 · 在JavaScript中,可以通过多种方式来获取包含某个特定文本的元素,如使用querySelector、遍历DOM、使用XPath等方法。以下是几种常见的方法:使用querySelector、遍历DOM、使用XPath。 一种常见的方法是使用JavaScript的querySelectorAll方法,然后通过遍历这些… Mar 15, 2024 · Right-click on the element code and select Copy → Copy XPath or Copy full XPath,allowing you to obtain an element's XPath. 该篇文档描述了如何在 JavaScript 中调用 XPath 接口。使用 XPath 的主要接口是 document 对象的 evaluate 函数。 Feb 11, 2025 · Note, in the above example, a more verbose xpath is preferred over common shortcuts such as //h2. All of the queries exported by DOM Testing Library accept a container as the first argument. This makes XPath Apr 18, 2025 · They represent a way to find element(s) on the page at any moment. click(); Yet the element wasn't selected in both cases and no click happened. Finding elements based on their XPath expression generally works very well and is flexible. XPath queries are mainly made using the Document class’s Evaluate() method. are you doing manual walking or using querySelector? – Raynos. Nevertheless, Aug 31, 2022 · document. The Document querySelector() Method. In fact it doesn't come from casperjs at all, and is supported by the browser, which is why it accepts CSS3 selectors, and not XPath. This Apr 25, 2023 · let p_tag = document. All other answers involve creating some wrapper function around querySelector, not directly using a single call to querySelector. Can querySelector select text nodes at all? I just wrote this short script; seems to work. locator to create a locator that takes a selector describing how to find an element in the page. Nov 8, 2023 · Browser automation is a powerful skill set, but it comes with unique challenges—including working with selectors and locators. querySelector('CSS-SELECTOR-FROM-DEVTOOL'); myEl. prototype. You started from the basics and then learned about their syntax and capabilities. pp = page. filter(function (el) { return el. (with the path //*[@id="search-button"] for example, it will just click on the Search button on this page. Utilizing Xpath for selection Jan 26, 2024 · 3. After going through this review, you can decide for yourself the best selector for web scraping. This is useful when an expression will be reused in an application, because it is just compiled once and all namespace prefixes which occur within the expression are preresolved. Playwright supports CSS and XPath selectors and auto-detects them if you omit css= or xpath= prefix. Description. evaluate() (DOM Level 3 XPath) is supported in Firefox, Chrome, Safari and Opera - the only major browser missing is MSIE. Between CSS, text and aria selectors, the use case for XPath should be very narrow nowadays. Jul 22, 2020 · It’s called XPath, and here’s how to use it. Nov 26, 2024 · xpath evaluate vs. The path part of XPath means that we need to specify the path from the beginning to the desired element. Automation tools rely on locators to find almost every component or element on the webpage. It was tough for me to figure that out so I figured I would put this up in case anyone else had this problem. const element = await page Nov 28, 2018 · 从接口定义可以看到Document、DocumentFragment、Element都实现了NodeSelector接口。 即这三种类型的元素都拥有者两个方法。 querySelector和querySelectorAll的参数须是符合css selector的字符串。 Both are extension methods defined in the AngleSharp. It helps in writing much better, readable and maintainable code. tagName. List elements implement Selector interface too. The problem here is that both syntax can have arbitrary strings in it: xpath: //*[contains(text(),"string")] This comparative review highlights the main differences between XPath vs. Puppeteer can be used to get an element by XPath. It uses XML document and queries it to identify elements within it. When implementing web scraping solutions, choosing the right selector method — CSS Selectors or XPath — can significantly impact your project’s efficiency, maintainability, and success. CSS selector being know that faster than xpath . querySelectorAll() //for multiple nodes To select by ID: document. log or inside your IDE or directly in VS Code with the VS Code Extension. Jun 20, 2023 · This will produce a rather long XPath expression, why an understanding of the XPath syntax is preferable here. Mar 22, 2025 · Advantages of Using XPath. Apr 20, 2019 · There is a very good plugin that can be used with selenium project shadow-automation-selenium. evaluate( xpathExpression, contextNode, namespaceResolver, resultType, result ); Learn how to use Playwright's querySelector and XPath for efficient web automation and testing. querySelector样式选择器进行html解析(一):将html转成xml使用xpath实现document. CSS selector guide, you explored the two most popular HTML query languages. match(regEx Dec 25, 2021 · For the sake of demonstration, we configured one test using the xpath locator and another using the querySelector. In this example, we are using the document. If no matches are found, null is returned. It's often faster than XPath when selecting elements because it leverages the browser's native CSS engine, which is optimized for parsing and matching. Traversing the DOM in older browsers like IE8 does not work with cssSelector but is fine with XPath. In this XPath vs CSS Selector guide, you will learn: What XPath expressions are, how they work, and their advantages and drawbacks. To use Puppeteer with XPath, you can use the `querySelector()` method. 组合定位 playwright 可以通过 CSS selector , XPath selector , HTML 属性(… Nov 2, 2011 · xpath vs DOM API. You know Dec 11, 2018 · XPath, the XML path language, is a query language for selecting nodes from an XML document. getElementById() vs document. 使用xpath实现document. 이 포스트는 사용 Jul 7, 2023 · This interface is a compiled XPath expression that can be evaluated on a document or specific node to return information from its DOM tree. You can use XPath axes like ancestor, descendant, following-sibling etc to select elements based on their position in the document. Xpath is easily extendable with additional functionality. See the docs for each query type to see available options, e. You can use XPath to find elements by their id, tag name, class name, and other attributes. XPath expressions can contain logical operators like and, or, as well as arithmetic operations and string functions. . querySelectorAll combined with ES6 spread to get array e. CSS Selector is purely based on the design of the application, the availability of the attributes in the DOM tree, and the complexity of the element structure. querySelector('div[SomeText*]'). [] filters those elements according to the predicate expressed therein. What are XPath selectors? XPath, or XMLPath, is a query language that uses non-XML XPath provides a wider range of options to target elements than CSS selectors. Feb 5, 2025 · This article seeks to document the difference between CSS Selectors and XPath for web developers to be able to better choose the right tool for the right job. a > :nth-child(2) + *'); But they both skips it and returns only the "p" element. g [document. querySelector(selector); Code language: JavaScript (javascript) document. Both querySelector() and querySelectorAll() throw a SYNTAX_ERR exception if the selector(s) is invalid. log(element); // This will log the element to the console. Use Relative XPath when the exact location of the element is less critical, or when you need to target elements based on their attributes, relationships, or content rather than their exact position in the document hierarchy. This post will explain the basics of XPath in easy-to-understand terms, giving you the tools to start scraping effectively. Locate by CSS or XPath. getAttribute Jan 9, 2018 · Historically, XPath was also used to select elements by text in Puppeteer, but this is no longer necessary since new syntax has been introduced specifically to select by text. querySelector样式选择器进行html解析(三):实现样式选择 Apr 14, 2025 · See the description of the translate function in the XPath specification for complete information about this function and its parameters. querySelector('CSS-PATH-FROM-DEVTOOL'); myEl. The Document getElementsByClassName() Method Feb 5, 2025 · The main interface to using XPath is the evaluate function of the document object. selector选择器 1. * @param {RegExp} regEx regular expression to match against tagName * @returns {Array} elements in the DOM that match */ function getAllTagMatches(regEx) { return Array. evaluate 関数ですが、理屈が分からないと使いにくいので、document. Advantages of XPath Allows navigation up the DOM when looking for elements; More flexible than CSS Selectors Puppeteer allows interacting with elements on the page through mouse, touch While those in favor of XPath tout it's ability to transverse the page (while cssSelector cannot). Targeting with XPath vs CSS. 그래서 자연스럽게 CSS Selector에 익숙해져 있었는데, Selenium과 Scrapy를 접하면서 XPATH를 사용하는 예제들이 많이 보였고 자연스럽게 XPATH에 대해서 알아보고 사용하게 되었다. 文章浏览阅读4. Dec 26, 2023 · XPath is a powerful tool for finding elements in a DOM. evaluate() returns an XPathResult based on an XPath expression and other given parameters. Therefore, this expression was able to Jun 20, 2022 · XPath What it is XPath stands for XML Path. querySelector() only accepts a valid css selector as argument, so taken literally, mine is the only answer that allows you to find an element by innerText using querySelector. Aug 3, 2021 · As you can see, XPath expressions have capabilities beyond CSS selectors. Step-by-step instructions: Jul 26, 2024 · querySelector() Returns the first matching Element node within the node's subtree. But there are already some research about this. call(document. click(); let myEl = document. querySelector('div. Apr 6, 2023 · 使用xpath实现document. querySelectorAll ('a')] but if you need to target deeply In this tutorial, we will provide an in-depth comparison of XPath vs CSS selector to help testers make an informed decision. While CSS selectors don't allow it. XPath は CSS セレクタよりもはるかにパワフル. Here's a breakdown of both methods: Performance: querySelectorAll() is generally well-optimized in modern browsers for CSS selector queries. Locating elements with XPath works very well with a lot of flexibility. XPath can walk up the DOM (e. 2k次。使用xpath实现document. Mar 20, 2017 · 本文介绍querySelector和querySelectorAll方法的应用,这两种方法简化了元素的选择过程,并提供了类似于jQuery的查询方式。 通过实例展示了如何使用这些方法来选择单一元素和元素集合。 Mar 19, 2024 · queryOptions . Aquí hay algunas cosas con las que podría empezar. See this post for details. Conclusion. using console. querySelector进行html解析(二):扩展一下xpath以便支持正则-----继续我们的工作,在进行下一步之前,先考虑一下,为_document xpath Feb 21, 2019 · document. Comparing this with the Copy selector option, which provides a CSS selector, can help you understand the differences between using XPath and CSS selectors. Parece que XPath é mais rápido que querySelectorAll() – Dec 18, 2023 · They leverage various strategies such as CSS, XPath, textual content, pseudo-selectors, and even custom properties you define. slice. This article provides some XPath code snippets — examples of how to implement a few utility functions. For instance, XPath selectors often begin with //, indicating a search anywhere in the document. Most developers quickly learn about the querySelector and querySelectorAll methods for querying the DOM with CSS selectors. Xpath can transform results before returning them. If no matching node is found, null is returned. In this XPath vs. querySelector (from document) vs parent. screen . Jun 1, 2024 · QuerySelector() to get the first HTML node that matches the CSS selector passed as an argument. querySelector() //for single node with css like path or selector document. The Evaluate(expression, contextNode, resolver, type, result) method accepts an XPath expression and other given parameters and returns a result of the specified type. innerTEXT;alert(text);但这当然行不通。 Jul 23, 2014 · xpath (query: str, namespaces: Mapping [str, str] | None = None, ** kwargs: Any) → SelectorList [_SelectorType] [source] ¶ Find nodes matching the xpath query and return the result as a SelectorList instance with all elements flattened. Setting the value of outerHTML replaces the element and all of its descendants with a new DOM tree constructed by parsing the specified htmlString. May 17, 2024 · Relative XPath: Relative XPath is more flexible and resilient to changes in the document structure. querySelector样式选择器进行html解析(二):扩展一下xpath以便支持正则. 0+ behavior This XPath, //*[contains(text(),'ABC')] behaves differently with XPath 1. I will just use what community has been found. The Element querySelectorAll() Method. If wanted we can also use XPath directly in CSS selectors such as in QuerySelector or QuerySelectorAll calls. Click the first Web element that matches an XPath Mar 29, 2023 · Hi ramya, I have tried like this: Use Shadow Path generator chrome extension and get the string value and by using js executor, click on the shadow dom and enter into it. Oct 14, 2024 · XPath Selectors: While identifying elements which do not have unique attributes or they are nested elements, for these conditions XPath is the most appropriate solution. The following illustrates the syntax of the querySelector() method: let element = parentNode. Examples The following example shows the use of the evaluate() method. In this article, we will try to cover complete functionality and the implementation of playwright selectors and locators. querySelector样式选择器进行html解析(三):实现样式选择器-----_document. While we typically use CSS to target input elements, XPath’s targeting method is similar but allows for some additional features. Here is the HTML for the examples. Playwright supports CSS and XPath selectors, and auto-detects them if you omit css= or xpath= prefix. ここまで CSS セレクタと比較しながら XPath をみてきましたが、XPath は CSS よりもはるかにパワフルにノードを指し示すことができます。CSS セレクタの完全上位互換と言ってもいいと思います 2 。 チートシート May 15, 2012 · document. querySelector(selector);}, // Returns all elements matching given selector in the root's subtree. Apr 3, 2023 · To locate this element using the class attribute, I have used the starts-with() method in this XPath vs CSS Selectors blog, and the XPath expression looks like this: As you can see in the above example of this XPath vs CSS Selectors blog, the class attribute value starts with the class name “mt-20”. HTML Overview Oct 12, 2020 · What is the easiest way to validate XPath / CSS selectors? Most of the browsers provide a built-in developer tools, which includes a handy feature that can evaluate or validate XPath/CSS selectors without any third-party extensions: browser console. How to use XPath Expressions in JavaScript. XPath expressions look very similar to the ones you would see when working with a traditional computer file Oct 10, 2023 · Playwright is a powerful test automation framework, allowing users to control web applications and conduct End to End test automation. The method returns an XPathResult based on the provided XPath expression and the supplied parameters. Selectors are strings, and they are the foundation of Playwright’s Aug 8, 2024 · With XPath, you’ll see less maintenance on the part of the QA tester. We pass the XPath as the argument, and the method returns the first element that matches the XPath. querySelector (from an element) querySelector vs querySelectorAll vs getElementsByClassName vs querySelector (ID) vs getElementsByID (2) aaaaafffffffffffffggg; querySelector vs getElementsByTagName Apr 6, 2023 · 使用xpath实现document. XPath provides axes, which allow for bidirectional traversal of the DOM tree and more complex element selection. css 选择器 2. getElementsByClassName (from document) vs parent. To return all matches (not only the first), use the querySelectorAll() instead. We can use the Prompt widget from Spectre. querySelector(xpath); console. XPath vs CSS selector for Test Automation May 8, 2016 · Document. evaluate() document. document. Time to dive in! XPath: Complete Analysis Apr 10, 2025 · The Document method querySelector() returns the first Element within the document that matches the specified CSS selector, or group of CSS selectors. querySelector([data-test-id=“name”]) as same as Keywords I trying but it not work WebUI. see the reference code below: Apr 9, 2025 · XPath offers more flexibility and advanced features compared to CSS selectors. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more. evaluate() 方法评估 XPATH 查询/表达式。因此,您可以在那里传递 XPATH 表达式,遍历 HTML 文档并找到所需的元素。 在 XPATH 中,您可以通过如下文本节点选择一个元素,获取具有以下文本节点的 div 。 //div[text()="Hello World"] Mar 30, 2021 · Playwright支持提供简写语法,根据内容自动判断选择器: 1. querySelector样式选择器进行html解析(一):将html转成xml 使用xpath实现document. Ask Question Asked 13 years, 2 months ago. querySelectorAll('#ID') //returns node list, you may need to use forEach To select by class: Feb 21, 2025 · Text content selection. innerText. The only solution I see here is selecting the previous node and then using nextSibling to access it. So, I ask them add an attribute into their code as same as data-test-id="name" for I finding element point. The Document getElementsByTagName() Method. XPath on the other hand, was specifically designed to provide a query language for XML documents and comes with a wide range of built-in functions. querySelector (v22) Revision 22 of this benchmark created on October 23, 2012. ¿Alguien me aclarará alguna comparación de rendimiento integral entre XPath y DOM en diferentes escenarios? He leído algunas preguntas en SO, como xPath vs DOM API, which one has a better performance y XPath or querySelector?. querySelector() vs document. js, you can debug it with your debugger of choice e. Apr 14, 2019 · I'm writing also a utility function to either use querySelector or xpath, and need to differenciate the 2. The querySelector() is a method of the Element interface. How XPath expressions and CSS selectors compare when it comes to performance, simplicity, and use cases. Compare the speed of xpath evaluate to querySelector. 以 // 或 / 或者 . highlight”) let p_text = p_tag. xpathを紹介します。 QuerySelector Methods: The Element querySelector() Method. querySelector(): Again each browser will result a slightly difference. GetElement Methods: The Document getElementById() Method. What CSS selectors are, how they work, and their pros and cons. When searching for web page elements by their attributes that contain references to files (for instance, the href attribute in A elements, the src attribute in IMG elements, etc. XPath namespace. querySelector() > FASTER > document. Mar 20, 2023 · Hello, As my case. Let’s consider the method parameters: expression is a string representation of the XPath to be Mar 5, 2024 · # Get Element by XPath using JavaScript - Examples. For this we only need to apply the following configuration: Feb 5, 2014 · 具体的サンプルの前に。 ブラウザでXpathを手軽に実行できる、document. If you must use CSS or XPath locators, you can use page. 0 vs XPath 2. Jul 12, 2024 · Reading the value of outerHTML returns a string containing an HTML serialization of the element and its descendants. querySelector("xpath=//h2") Nov 19, 2019 · 처음 python으로 크롤러를 만들때 requests와 bs4를 사용하였는데, bs4에는 XPATH에 대한 개념이 존재하지않았다. queryAll(root, selector) Mar 25, 2018 · Propriamente dito querySelector() ou querySelectorAll() são seletores de CSS já XPath é próprio para DOM (seletor de nós) eu mesmo já não uso mais e nunca fiz questão de testar mas depois de seu comentário fiz uma breve pesquisa e encontrei este teste em jsperf. 试着用这样的东西:var text = document. querySelector样式选择器进行html解析(三):实现样式选择器. getElementsByClassName (from an element) document. W3Schools offers free online tutorials, references and exercises in all the major languages of the web. "Increasing page size" - my Sep 5, 2017 · let myEl = document. Feb 5, 2025 · This document describes the interface for using XPath in JavaScript. The next step is to present the user with the list of available books. Commented Nov 2, 2011 at 11:42. 0 and later versions of XPath (2. Ninguno de ellos menciona casos específicos. Aug 22, 2024 · Xpath can traverse HTML trees in every direction and is location-aware. For example, XPath expressions can find an element based on its text content. 0, you can apply text pattern matching with matches(). Considering the above scenario, you can see that choosing XPath vs. queryselector xpath When to use XPath expressions. Common behavior //* selects all elements within a document. querySelector(“p. As HAP natively supports XPath expressions, you should prefer them over CSS selectors. querySelector样式选择器进行html解析(四):将选择结果封装进行输出. CSS Selector. querySelector('#ID') //returns single element document. The web is a dynamic environment, and writing scripts that are still likely to work in a few months (or years) takes some practice. This is because the evaluation of the query does not waste time visiting unnecessary nodes. First, let’s discuss the XPath selectors for web scraping. But if yon't know which element selection language is best for you, read our comparison article on XPath vs CSS selector . The querySelector() method returns the first element that matches a CSS selector. Jan 31, 2020 · 选择器 描述 [用于选取带有指定属性的元素。 [attribute=value]用于选取带有指定属性和值的元素。 [attribute~=value]用于选取属性值中包含指定词汇的元素。 So, you can simply go for the CSS selectors. Apr 9, 2025 · If the provided context node is not a type permitted as an XPath context node or the request type is not permitted by the XPathEvaluator, a DOMException of type NOT_SUPPORTED_ERR is raised. Modern answer that covers XPath 1. The "Hello World!" can be in its id, its value, its name, its title, its onclick etc, anywhere. I can not find element by id or class because FE dev using a framework and it will be generation random id, class. What is Locator? Locators are used to select the specific element in the DOM tree. ), keep in mind that such references quite often contain relative file paths in May 7, 2016 · 怎样才能找到带有特定文本的DIV?例如: SomeText, text continues. XPath Cheat Sheet illustration What is XPath? XPath stands for XML Path Language, a tool used to navigate through elements and attributes in an XML document. 3. If you absolutely must use CSS or XPath locators, you can use page. querySelector and document. locator to create a locator that takes a selector describing how to find an element in the page Jul 9, 2015 · There have been couple of recent posts asking about using KM to click on particular elements on web pages. evaluate() Sep 25, 2024 · 使用JavaScript根据文本内容定位标签的方法有很多,包括 querySelector、getElementsByClassName、getElementsByTagName 以及 XPath 等。 使用 querySelector、innerText 结合正则表达式、结合 XPath 定位特定文本内容、遍历 DOM 树来查找文本内容。 I think main advantage of XPath is its ability to go UP the tree structure of DOM. These functions can be used to perform calculations and extract specific information from the elements. For example: Oct 22, 2017 · Most of the time, I prefer document. xpath 语法定位 3. Jan 23, 2014 · So, it turns out that the querySelectorAll method doesn't actually support XPath. Use the document. querySelectorAll('*')). 在这篇 XPath 与 CSS 选择器指南中,您将了解到: XPath 表达式是什么、如何工作及其优点和缺点。 CSS 选择器是什么、如何工作及其优缺点。 XPath 表达式与 CSS 选择器在性能、简洁性和使用案例方面的比较。 现在开始深入了解吧! XPath:全面分析 querySelector() 方法返回文档中匹配指定 CSS 选择器的一个元素。 注意: querySelector() 方法仅仅返回匹配指定选择器的第一个元素。如果你需要返回所有的元素,请使用 querySelectorAll() 方法替代。 return root. XPath, which stands for XML path language, is a query language that is used to select nodes from an XML document. 0+). Before we dig into Xpath let's have a quick overview of HTML itself and how it enables xpath language to find anything with the right instructions. Here is a generic macro which clicks on the first item (in Safari or Chrome) which matches an XPath expression in a KM variable. /** * Find all the elements with a tagName that matches. XPath snippets. byRole API. These functions are based on standard interfaces from the DOM Level 3 XPath specification that expose XPath functionality to JavaScript code Since Playwright runs in Node. The syntax is: var xpathResult = document. In XPath 2. CSS. Playwright locator by class name and text Learn how to use Playwright to locate elements by class name and text efficiently. a > :nth-child(3)'); And even by using next sibling: document. Console to present all titles: Dec 30, 2015 · 2. It’s compatible with old browsers (or it was at time of publishing—including older versions of Internet Explorer, which some corporations still use). querySelector进行html解析(一):将html转成xml使用xpath实现document. query is a string containing the XPATH query to apply. Fine-grained attribute-based selection and data extraction. For example, you need to select the button (in order to simulate click on it) which is placed inside some container without any attrubites (class attribute or whatever) and the only thing you Apr 18, 2025 · Locate by CSS or XPath. This flexibility Oct 2, 2024 · XPath can help you pull specific information from websites. Using this you can access multi level of shadow DOM (up to 4 levels). The Document querySelectorAll() Method. Jun 3, 2021 · document. com. You can pass a queryOptions object with the query type. 9k次。使用xpath实现document. querySelector样式选择器进行html解析(二):扩展一下xpath以便支持正则使用xpath实现document. pntgl yqohu zirl qozv mbgg kyde uhmyie mdjqh xie cqui peoz bacom gdt hdunrtd jexwui