xpath-1.0

Unable to locate element and TimeoutException when WebDriverWait is used

北慕城南 提交于 2019-12-02 13:03:31
I'm trying to automate the clicking of the "SHOW MORE" button at the bottom of the page to get all the reviews there is. However, I'm having some problems locating it and would really appreciate it if you could help me out. I have tried a couple of methods but I am not sure why none of them work. 1) Method 1: CSS Selector driver.find_element_by_css_selector("U26fgb.O0WRkf.oG5Srb.C0oVfc.n9lfJ.M9Bg4d") leads to: NoSuchElementException: Message: no such element: Unable to locate element 2) Method 2 : XPath Helper (an extension on Chrome) driver.find_element_by_xpath("/html/body[@id='yDmH0d']/div[

Aggregate-function for sum and product in XPath

Deadly 提交于 2019-12-02 01:14:36
问题 Similar to this question (http://stackoverflow.com/q/1333558/948404) I want to use XPath to calculate a sum over products in a structure like this: <items> <item> <value>1.0</value> <quantity>3</quantity> </item> <item> <value>2.5</value> <quantity>2</quantity> </item> <!-- ... --> </items> Is there an XPath expression that calculates the sum of the products of each items value and quantity ? Update: The solution has to work with PHPs XSLTProcessor class meaning that it probably has to be

Aggregate-function for sum and product in XPath

馋奶兔 提交于 2019-12-01 20:23:57
Similar to this question (http://stackoverflow.com/q/1333558/948404) I want to use XPath to calculate a sum over products in a structure like this: <items> <item> <value>1.0</value> <quantity>3</quantity> </item> <item> <value>2.5</value> <quantity>2</quantity> </item> <!-- ... --> </items> Is there an XPath expression that calculates the sum of the products of each items value and quantity ? Update: The solution has to work with PHPs XSLTProcessor class meaning that it probably has to be XSLT 1.0 compliant. This is why I did not yet accept the two probably correct answers using XSLT 2.0. I

Apply a predicate to the current node

本秂侑毒 提交于 2019-11-28 04:36:50
问题 (I'm posting this self-answered question because the typically offered solution to this issue is needlessly verbose and I'd like to set the record straight. I couldn't find an existing SO question for this, but if there is one, please close this as a duplicate.) I am looking for a way to perform an XPath selection to select the current node only if it matches a certain condition. This would be useful, for example, when I want to conditionally apply an XSLT template to the current node: <xsl

How to find the max attribute from an XML document using Xpath 1.0

我怕爱的太早我们不能终老 提交于 2019-11-27 15:08:01
Is there a way to query an XML document to return the maximum of a given attribute using Xpath 1.0 ? For example is there a way to get the max id ? <?xml version="1.0" encoding="utf-8"?> <library> <book id="2" name="Dragon Tatoo"/> <book id="7" name="Ender's Game"/> <book id="3" name="Catch 22"/> <book id="1" name="Lord of the rings"/> </library> In XPath 2.0, use the max function. To find the book with the highest id , do /library/book[@id = max(/library/book/@id)] The following XPath selects the book with highest id: /library/book[not(@id <= preceding-sibling::book/@id) and not(@id <

How to use starts-with() , contains() and ends-with() in XPath to find the xml node innertext? in XPATH 1.0

有些话、适合烂在心里 提交于 2019-11-27 08:56:30
<ArticleBackmatter> <Heading>Ethical standards and patient consent</Heading> <Heading>Ethical standards and patient</Heading> <Heading>standards and patient consent</Heading> </ArticleBackmatter> I want to get the inner text with start from "Ethical" , contains "and " and end with "consent" in the Heading node. har07 One possible way: //Heading[starts-with(., 'Ethical') and ends-with(., 'consent')] The ends-with() function is XPath 2.0. In XPath 1.0, it can be replaced using substring() and string-length() . Here is the equivalent XPath 1.0 (wrapped for readability): //Heading[ starts-with(.,

Check type of node in XSL template

浪子不回头ぞ 提交于 2019-11-27 06:04:50
问题 Is it possible to check the type of a node I matched with a template inside the same template? In case it is, how can I do it? For example I would like to do something like this: <xsl:template match="@*|node()"> <xsl:choose> <xsl:when test="current() is an attribute"> <!-- ... --> </xsl:when> <xsl:when test="current() is an element"> <!-- ... --> </xsl:when> <xsl:otherwise> <!-- ... --> </xsl:otherwise> </xsl:choose> </xsl:template> 回答1: Take a look at this answer here, as this should give

Encoding XPath Expressions with both single and double quotes

你离开我真会死。 提交于 2019-11-27 04:29:49
XPath (v1) contains no way to encode expressions. If you only have single OR double quotes then you can use expressions such as //review[@name="Bob's Pizza"] //review[@name='"Pizza" Pam'] But if you have BOTH e.g [Fred's "Fancy Pizza"] then you have to use something like this Escaping Strings in XPath (C++) to generate //review[@name=Concat("Fred's ",'"Fancy Pizza"')] Anyone have a function in c# to do this? Some links that are close Use the MVP.XML library and XPathVariable (a very good solution but a bit heavyweight for my needs). Doesn't encode where both " and ' are present Adds more

How to handle double quotes in string before XPath evaluation?

瘦欲@ 提交于 2019-11-26 21:06:43
In the function below, when string in $keyword contains double quotes, it does create a "Warning: DOMXPath::evaluate(): Invalid expression" : $keyword = 'This is "causing" an error'; $xPath->evaluate('boolean(//img[contains(@alt, "'.$keyword.'")])'); What should I do to prep $keyword for the evaluate xpath expression? The full function code: $keyword = trim(strtolower(rseo_getKeyword($post))); function sx_function($heading, $post){ $content = $post->post_content; if($content=="" || !class_exists('DOMDocument')) return false; $keyword = trim(strtolower(rseo_getKeyword($post))); @$dom = new

How to find the max attribute from an XML document using Xpath 1.0

岁酱吖の 提交于 2019-11-26 18:28:52
问题 Is there a way to query an XML document to return the maximum of a given attribute using Xpath 1.0 ? For example is there a way to get the max id ? <?xml version="1.0" encoding="utf-8"?> <library> <book id="2" name="Dragon Tatoo"/> <book id="7" name="Ender's Game"/> <book id="3" name="Catch 22"/> <book id="1" name="Lord of the rings"/> </library> 回答1: In XPath 2.0, use the max function. To find the book with the highest id , do /library/book[@id = max(/library/book/@id)] 回答2: The following