XPathSelectElement always returns null

When namespaces are used, these must be used in the XPath query also. Your XPath query would only work against elements with no namespace (as can be verified by removing the namespace from your XML). Here’s an example showing how you create and pass a namespace manager: var xml = … XML from your post … Read more

XPath find text in any text node

This expression //text() = ‘Alliance Consulting’ evals to a boolean. In case of this test sample: <r> <t>Alliance Consulting</t> <s> <p>Test string <f>Alliance Consulting</f> </p> </s> <z> Alliance Consulting <y> Other string </y> </z> </r> It will return true of course. Expression you need should evaluate to node-set, so use: //text()[. = ‘Alliance Consulting’] E.g. … Read more

selenium – Failed to execute ‘evaluate’ on ‘Document’: The string is not a valid XPath expression

This error message… SyntaxError: Failed to execute ‘evaluate’ on ‘Document’: The string ‘//span[contains(@class, ‘md_countryName_fdxiah8’ and text(), ‘Colombia’)]’ is not a valid XPath expression. …implies that the XPath which you have used was not a valid XPath expression. Seems you were pretty close. You can use either of the following Locator Strategies: Using xpath 1: country … Read more

How to retrieve partial text from a text node using Selenium and Python

To print text … you have to induce WebDriverWait for the visibility_of_element_located() and you can use either of the following Locator Strategies: Using CSS_SELECTOR, childNodes and strip(): print(driver.execute_script(‘return arguments[0].firstChild.textContent;’, WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, “a.call_recipe[href^=’/recipes’]”)))).strip()) Using XPATH, get_attribute() and splitlines(): print(WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, “//a[@class=”call_recipe” and starts-with(@href, ‘/recipes’)]”))).get_attribute(“innerHTML”).splitlines()[1]) Note : You have to add the following imports : from selenium.webdriver.support.ui … Read more

Google Sheet use Importxml error could not fetch url [duplicate]

You want to retrieve the price like 55,500₽ from the URL of https://tarkov-market.com/item/Pack_of_sugar and put to a cell on Google Spreadsheet. I could understand like this. If my understanding is correct, how about this answer? Issue and workaround: Unfortunately, IMPORTXML cannot be used for this situation. Because IMPORTXML is used like =IMPORTXML(“https://tarkov-market.com/item/Pack_of_sugar”,”//*”), an error like … Read more

Concatenate grouped rows

Use: select t.id, sum(t.price) , stuff(( select distinct ‘,’ + cast(t2.ServiceID as varchar(max)) from @t t2 where t2.id = t.id for xml path(”) ), 1, 1, ”) from @t t group by t.id Output: ———– ——————— ——————— 1 40,00 11,12 2 120,00 11

tech