FAQ Database Discussion Community


How to get all direct(immediate) rows from WebElement Table

selenium,xpath,css-selectors
From the below table I need immediate row elements using Xpath or "css-selector" or Selenium API :- element.findelements. Please help. <table id ="Main"> <tbody> <tr id="row_1"> <tr id="row_1_1"> <tr id="row_1_1_1"> </tr> </tr> </tr> <tr id="row_2"> </tr> <tr id="row_3"> <tr id="row_3_1"> </tr> </tr> </tbody> </table> Expected Output:- [<tr id="row_1">,<tr id="row_2">,<tr id="row_3">]...

xpath query seem to be failing

xml,xpath
Can someone tell me the reason for the failure of this xpath query: //Pages/*[(name() = 'Home') or following-sibling::Home] on this xml structure: <Pages> <copyright>me inc. 2015,</copyright> <author>Me</author> <lastUpdate>2/1/1999</lastUpdate> <Home>--------------------</Home> <About>--------------------</About> <Contact>------------------</Contact> </Pages> only returned copyright element, which is against my targets (To grab all element between Pages and...

grabbing value from html by xpath in python

python,html,xpath
I want to use xpath for grabbing WhatIwant phrase: a="<b>AAA:</b> BBB<br/><br/><img src='line.gif' /><br/><br/><b><font size='2'>Text: </b>WahtIwant</font><br/><center>" I want to grab WahtIwant from a: tree=html.fromstring(a) tree.xpath('//font[@size="2"]/text()') ['Text: '] ...

Selenium Webdriver: how to use xpath filter?

java,selenium,xpath,webdriver
I'm trying to follow the Selenium Webdrive Basic Tutorial in the case of using HTML tables here http://www.toolsqa.com/selenium-webdriver/handling-tables-selenium-webdriver/ The code of "Practice Exercise 1" in that page doesn't work: the problem seems to be about the xpath filter here String sCellValue = driver.findElement(By.xpath(".//*[@id='post-1715']/div/div/div/table/tbody/tr[1]/td[2]")).getText(); and here driver.findElement(By.xpath(".//*[@id='post-1715']/div/div/div/table/tbody/tr[1]/td[6]/a")).click(); The page used in...

Read XML by xpath containing namespace prefix

c#,xml,xpath,xmldocument
im trying to read from this http://api.hostip.info/?ip=12.215.42.19 XmlDocument xml = new XmlDocument(); xml.Load("http://api.hostip.info/?ip=79.177.176.8"); XmlNodeList xnList = xml.SelectNodes("gml:featureMember/Hostip"); foreach (XmlNode xn in xnList) { string Name = xn["countryName"].InnerText; MessageBox.Show(Name); } im getting a weird error Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function. never seen...

Extract value of a input hidden DOMXpath php

php,xpath,input,hidden,nodevalue
I need take the attribute value using xpath, I tried several times but always get null. Here is my html code: <input type="hidden" id="Lat" name="myMap" value="22.445575, -18.722164"> Code in php: $val= $xpath->query('//input[@type="hidden" and @name="myMap"][email protected]' ); $list=array(); foreach($val as $v){ $list[]=$v->nodeValue; } var_dump($list); $sValue= (string)$val[0]; Notes: I've tried with other xpath...

Scrapy not giving individual results of all the reviews of a phone?

python,xpath,web-scraping,scrapy,scrapy-spider
This code is giving me results but the output is not as desired .what is wrong with my xpath? How to iterate the rule by +10. I have problem in these two always. import scrapy from scrapy.contrib.spiders import CrawlSpider, Rule from scrapy.selector import Selector from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor from urlparse...

Unable to construct Document object from xml string

java,xml,xpath,xml-parsing
I have xml string coming to my appliaction like follows <?xml version="1.0" encoding="UTF-8"?><loc:getLocation xmlns:loc="http://www.csapi.org/schema/parlayx/terminal_location/v2_3/local"> <loc:address>tel:+919420161525</loc:address> <loc:requestedAccuracy>500</loc:requestedAccuracy> <loc:acceptableAccuracy>500</loc:acceptableAccuracy> </loc:getLocation> I want to construct Document object from this so that using XPath, I can retrieve required data. I tried following code...

With XPath, get a button from a row, that has a cell with a specific text

html,xpath
I have a rather tricky xpath situation here. I will illustrate it. Here are my HTML elements: <table> <tr> <td> <button>Click 1<button> </td> <td>ABC</td> <td>DEF</td> </tr> <tr> <td> <button>Click 2<button> </td> <td>MNO</td> <td>PQR</td> </tr> <tr> <td> <button>Click 3<button> </td> <td>UVW</td> <td>XYZ</td> </tr> </table> So, I want to traverse the...

How to set up XPath query for HTML parsing?

python,xml,parsing,xpath,lxml
Here is some HTML code from http://chem.sis.nlm.nih.gov/chemidplus/rn/75-07-0 in Google Chrome that I want to parse the website for some project. <div id="names"> <h2>Names and Synonyms</h2> <div class="ds"><button class="toggle1Col"title="Toggle display between 1 column of wider results and multiple columns.">&#8596;</button> <h3 id="yui_3_18_1_3_1434394159641_407">Name of Substance</h3> <ul> <li id="ds2"> `` <div>Acetaldehyde</div> </li> </ul>...

scrapy xpath not returning desired results. Any idea?

html,xpath,scrapy
Please look at this page http://164.100.47.132/LssNew/psearch/QResult16.aspx?qref=15845. As you would have guessed, I am trying to scrape all the fields on this page. All fields are yield-ed properly except the Answer field. What I find odd is that the page structure for the question and answer is almost the same (Table[1]...

XSL getting out of context using dynamic XPATH

xslt,xpath
I'm trying to reformat an XML I get from an appliance into an HTML table, and it's format is not usual. It use unique references in node name's, like this: /network/content/host/content/REF_1/content /network/content/network/content/REF_2/content and then, it use the same references to another part of the file, as a value of a...

How to fetch attribute value of parent node from child nodelist.(XPath)

xml,xpath,xml-parsing,attributes,parent-node
Here's the requirement I have a xml document which looks something like this -<page height="777" width="777"> -<block r="777" l="777" blockType="Separator"> +<region> +<separator> -<block r="777" l="777" blockType="Separator"> +<region> +<separator> -<block r="777" l="777" blockType="Text"> +<region> +<text> </page> I have all the separator blocks in separatorNodeList String expression = "//page/block/separator"; XPathExpression expr =...

How to reject specify HTML tags by using css or xpath selector

javascript,css,ruby,xpath,nokogiri
I want to remove style and script tags and the contents of them by using css or xpath selector. This is a example HTML: <html> <head> <title>test</title> <style> // style </style> <script> /* some script */ </script> </head> <body> <p>text</p> <script> /* some script */ </script> <div>foo</div> </body> </html> I...

I want to find the xpath for day separated by

java,html,xpath,selenium-webdriver
I have an HTML like this <td class="FormLabel" valign="top"> <span class="DataLabel">Consists of:</span> </td> <td class="FormData"> <span class="BodyText"> Sunday<br> Monday<br> </span> </td> Here I want Xpath to just check for Sunday. I had written Xpath like this //span[contains(.,'Consis')]/parent::td/following-sibling::td/span[contains(.,'Sun')] But this is not working as it is showing both days sunday and...

XSD unique element XPath limitations

xml,xpath,xsd,unique
In order to allow an element to appear multiple times but restrict it to element values only being allowed once I'm applying the unique element. I've only got it working in an inefficient manner due to the XPath limitations within XSD 1.0 though. XSD 1.1 is unfortunately not an option...

XSL transformation outputting multiple times and other confusion

xml,xslt,xpath
I'm attempting to transform a section of an XML document (which is mostly HTML) with a templated piece of markup should a particular pattern be matched. I'm inexperienced with XSLT (I've only used xpath, really) and online documentation is sparse so I'm struggling with it... To the following XML document:...

There is no element matching XPath “//html” (Behat\Mink\Exception\DriverException)

symfony2,xpath,behat,mink,symfony-2.7
I really can't figure out why Mink / Behat cannot find "Login" text. My scenario is simple enough: Scenario: Valid Registration Given I am on "/register/" Then the response status code should be 200 Then print current URL Then show last response Then I should see "Login" And the output...

Select multiple blocks of nodes including the start and end nodes with XPath 1.0

php,xpath
The following is a simplified version of my XML: <div><p class="start">1</p></div> <div><p class="data">2</p></div> <div><p class="data">3</p></div> <div><p class="end">4</p></div> <div><p class="data">5</p></div> <div><p class="start">6</p></div> <div><p class="data">7</p></div> <div><p class="end">8</p></div> This is a simplified...

xpath: how to select items between item A and item B

xpath,scrapy
I have an HTML page with this structure: <big><b>Staff in:</b></big> <br> <a href='...'>Movie 1</a> <br> <a href='...'>Movie 2</a> <br> <a href='...'>Movie 3</a> <br> <br> <big><b>Cast in:</b></big> <br> <a href='...'>Movie 4</a> How do I select Movies 1, 2, and 3 using Xpath? I wrote this query '//big/b[text()="Staff in:"]/following::a' but it returns...

Update Text Field While Automating iPhone App

iphone,xpath,textbox
I am automating an iPhone App. The scenario is Login Logout and re-Login. But while re-login the username and password field is displaying the details. I am trying to list that xpath as a WebElement and clear() that field if(Webelement.gettext() !="") But it is not happening as in the existing...

Seach by class in Nokogiri nodeset

ruby,xpath,nokogiri
I got the name of a CSS class from a Nokogiri node. Now I want to find all the nodes that also have the same class attached. I don't know which HTML tag the element that I'm looking for has, and how deep it is. All i know is what...

How to identify an element via XPath when IDs keep changing

html,xml,xpath,selenium-webdriver,web-scraping
I am using a website, where the values of the elements are changing dynamically every time the elements load. The id's are dynamic and so is the XPath. I don't seem to have any unique identifier to locate the elements. Please advise on the best way to uniquely identify the...

Adding a public class to click using xpath with Java Selenium

java,selenium,xpath
I am trying to create a public class to click an item on a webpage with selenium by just passing it the xpath and driver I'm using. I want to be able to just do: ClickByXpath(driver, "/html/body/div/div[3]/form/div[2]/div[2]/div[1]/div[1]/div[3]/div/div[3]/div/input[1]"); Here's the code I'm using, but it's complaining that the method xpath string...

Error when building an XDocument

c#,xml,linq,xpath,linq-to-xml
Using the following example xml containing one duplicate: <Persons> <Person> <PersonID>7506</PersonID> <Forename>K</Forename> <Surname>Seddon</Surname> <ChosenName /> <MiddleName /> <LegalSurname /> <Gender>Male</Gender> </Person> <Person> <PersonID>6914</PersonID> <Forename>Clark</Forename> <Surname>Kent</Surname> <ChosenName>Clark</ChosenName> <MiddleName />...

Test XML content without using mock mvc

xml,spring,unit-testing,xpath,spring-test
I am using spring test with mockmvc and it works like a charm to test xml output! Example: ResultActions actions = this.mockMvc.perform(get("/entry/NX_P38398/overview.xml")); actions.andExpect(xpath("entry/overview/gene-name-list/gene-name[@type='recommended']").exists()); actions.andExpect(xpath("entry/overview/gene-name-list/gene-name[@type='recommended']").string("BRCA1")); I would like to take advantage of the same features to test an OutputStream without using mockmvc and controllers. Is it possible to use the same...

Searching a list of similar elements for a given value

xpath,nokogiri
I have some XML like this: <Team ...some attributes...> <Name>My Team</Name> <Player uID="player1"> <Name>Name</Name> <Position>Goalkeeper</Position> <Stat Type="first_name">Name</Stat> <Stat Type="last_name">Last</Stat> <Stat Type="birth_date">bday</Stat> <Stat Type="birth_place">bplace</Stat> <Stat Type="weight">84</Stat> <Stat Type="height">183</Stat> <Stat Type="jersey_num">1</Stat>...

Match parent only if children exists in xpath

xpath
('//div[contains(@class, "myClass")]') //all the occurrences I need to select from those only the ones that have a div inside with the class "tec", also the <div class="tec"> is a grandchildren of <div class="myClass"> Just in case: <div class="myClass"> <div class="other-div1"></div> <div class="sibling"> <div class="tec">"Content."</div> <div class="other-div2"></div> </div> </div> I need...

Scraping using DomXPath

php,xpath
Using PHP DomXPath to scrape some websites. Currently using this tutorial to traverse XPaths. I am currently scraping this site, getting the character names and Steam ID (the mess of an XPath below is what gets one Steam ID). My question is - there are multiple Steam IDs and character...

Iterating through a list of elements inside an element with a specific index

c#,xml,linq,xpath
I have an XML-document that I'm trying to extract data from. <folder> <list index="1"> <item index="1" > <field type="IMAGE"> <url>https://www.test.com/0001.png</url> </field> </item> <item index="2"> <field type="IMAGE"> <url>https://www.test.com/0002.png</url> </field> </item> </list> etc... I'm trying to get a list of all the fields that have the type "IMAGE" inside of the list...

Java XPath returns single result instead of NodeSet

java,xml,dom,xpath
I am trying to create an XPath expression in Java (8, default XPath implementation). I am doing the following: Object res = xpath.evaluate("(//*[local-name()='PartyId'])", requestDom, XPathConstants.NODESET); I have multiple PartyId nodes in the document at the same level, because it's parent is repeating. I got my result, but only a single...

Xpath for Find & Replace?

xml,xpath,replace
Fellow Forum Members, I'm new to Xpath and have the following question. Let's say for example I have 300 separate XML files and I need to make a global text change that may impact only 40 of the XML files. Is it possible using Xpath to perform a find &...

XPath query to select ONLY unique nodes

c#,xml,xpath,selectnodes
I have what is hopefully a very simple XPath query to build that I'm stuck on (very new to XPath). I have the following xml: <?xml version="1.0" encoding="utf-8"?> <Persons> <Person> <PersonID>6352</PersonID> <Forename>Tristan</Forename> </Person> <Person> <PersonID>6353</PersonID> <Forename>Ruth</Forename> </Person> <Person> <PersonID>6913</PersonID> <Forename>Mina</Forename> <Surname>Asif</Surname>...

Convert contents of an XmlNodeList to a new XmlDocument without looping

c#,xml,xpath,xmldocument,xmlnodelist
I have Xml that I filter using XPath (a query similar to this): XmlNodeList allItems = xDoc.SelectNodes("//Person[not(PersonID = following::Person/PersonID)]"); This filters all duplicates from my original Persons Xml. I want to create a new XmlDocument instance from the XmlNodeList generated above. At the minute, the only way I can see...

Check for xpath duplicates while running a for loop in scrapy for python

python,xpath,scrapy
I'm scraping xml data through scrapy and at the same time I want to check on duplicates. For this I'm using the following code: arr = [] for tr in response.xpath('/html/body/table[1]'): if tr.xpath('tr/td/text()').extract() not in arr: arr.append(tr.xpath('tr/td/text()').extract()) print arr This yields the following output (demo data): [[u'test1', u'12', u'test2', u'12',...

BaseX XQuery error: root(): no context value bound

xpath,xquery,grouping,basex
I am trying to run the following XQuery expression in BaseX to extract elements between two succeeding headings. (as an article section). xquery for $x in doc("test.xq")//h2, $y in $x/following-sibling::h2[1] return //*[$x/following::* and $y/preceding::*] But it gives the error Error: Stopped at D:/Program Files/BaseX/data/test.xq, 1/74: [XPDY0002] root(): no context value...

Xpath text() wrong output

python,xpath,web-scraping,scrapy
This is my first scrapy program! I'm writing a program using python/scrapy and I've tested my Xpath in FirePath and it works perfectly, but it is not displaying properly in the console (still in the early testing phase) What I'm doing is attempting to scrape a page of amazon reviews....

How to get xml Nodes which are in lower case using XSLT 1.0

xml,xslt,xpath,xslt-1.0
I need to get XML nodes which are in lower case and values of it using XSLT 1.0 and display the output as XML <main> <ACAT>Cat Name A </ACAT> <bcat>Cat Name b </bcat> <ccat>Cat Name c </ccat> <dcat>Cat Name d </dcat> <ECAT>Cat Name E </ECAT> <fcat>Cat Name f </fcat> </main>...

selenium webdriver - xpath locator not working if element's text contains Unicode Characters

selenium,xpath,unicode,selenium-webdriver,webdriver
I'm trying to select an option contained inside a menu. It's not a select menu, but it's styled to appear as such. Anyway, if the text contained inside the menu is in English, I can select it ok. Trouble is, the text I need to select is french so it...

How to retrieve ATTRIBUTE VALUE from specific ELEMENT VALUE in C#

c#,xml,xpath
I have an XML file structured like this: <?xml version="1.0" encoding="utf-8"?> <PresCrt> <Times> <Time hours="0">2015-06-20T00:00:00Z</Time> <Time hours="12">2015-06-20T12:00:00Z</Time> <Time hours="24">2015-06-21T00:00:00Z</Time> <Time hours="36">2015-06-21T12:00:00Z</Time> <Time hours="48">2015-06-22T00:00:00Z</Time> <Time hours="60">2015-06-22T12:00:00Z</Time> <Time hours="72">2015-06-23T00:00:00Z</Time> <Time...

How to access second element using relative Xpath

firefox,xpath,selenium-webdriver,selenium-ide,robotframework
Given this page snippet <section id="mysection"> <div> <div> <div> <a href=""> <div>first</div> </a> </div> <div> <a href=""> <div>second</div> </a> </div> </div> </div> </section> I want to access the second a-element using relative Xpath. In FF (and locating with Selenium IDE) this //section[@id='mysection']//a[1] works but this does not match //section[@id='mysection']//a[2] What...

XPath for child element

selenium,xpath
What is the Xpath to select the first element of this jquery selector: $('.A .B:eq(1)') ? HTML Sample <div class="x A z"> <div class="y"> <div class="r B z"></div> <---- that is that I need to select <div class="r B z"></div > ... So far I've tried this: (//div[(@class='A') and div[contains(concat('...

Can I create a macro or shortuct for a step of XPath in XQuery?

xml,xpath,macros,xquery
Do we have Macros in XQuery? If yes, could you please give an example of their usage. I have the following code let $x := //price/ancestor::* Can I someway, using macros or other things write it as follows: let $x := //price/outward So, the outward should mean ancestor::*...

webdriver C# - click this element with XPath position?

c#,selenium,xpath,webdriver
I have an element whit this XPath Position: //td[4]/a I try this but does not work: driver.FindElement(By.XPath(".//*[@position='//td[4]/a']")).Click(); Using C# Webdriver and not java, please....

Getting href-attributes using XPath in PHP

php,xpath,domdocument
I am new to PHP and trying to write a scrapper for a website. I am trying to get an element with class name categories. I have use $showPage = '<li class="categories">Categories<ul> <li class="cat-item cat-item-940"><a href="http://www.desitvbox.me/category/star-plus/amul-taste-of-india/" >Amul Taste of India</a> </li> <li class="cat-item cat-item-942"><a href="http://www.desitvbox.me/category/star-plus/dance-plus/" >Dance Plus</a> </li> <li class="cat-item...

How to add spaces between nodes when using string() on a tree in XPath

html,xslt,xpath,lxml
I have a HTML tree where I use the 'string()' query on the root to get all the text from the nodes. However, I'd like to add a space between each nodes. I.e. string() on '<root><div>abc</div><div>def</div></root>' will become 'abcdef' string() on '<root><div>abc</div><div>def</div></root>' should become 'abc def '...

XSLT insert sibling if it doesn't exist - Not being rerunnable for some reason

xml,xslt,xpath
I'm trying to add a sibling to an element only if it doesn't exist. Here's my XML: <?xml version='1.0' encoding='UTF-8'?> <domain xmlns="http://xmlns.oracle.com/weblogic/domain" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/security/xacml http://xmlns.oracle.com/weblogic/security/xacml/1.0/xacml.xsd http://xmlns.oracle.com/weblogic/security/providers/passwordvalidator...

XPath: get closest heading element (h1, h2, h3, etc.)

php,xpath
I want to select the heading element (whether h1, h2, h3, h4, h5 or h6) that is closest above the form using XPath in PHP. <h2>Foo</h2> <h3>Bar</h3> <form> <input /> </form> The example above should return the h3 (Bar) because it is closest to the form. <h4>Kee</h4> <form> <input />...

how to make xml values comma seperated using XPath, XQuery in Sql Server

sql-server,xml,xpath,xquery
I have an xml column with sample values as <error> <errorno>BL04002055</errorno> <description>Smart Rule PROJECT_COUNTRYCODE_VAL Violated</description> <description2>Country Code is required</description2> <correction /> </error> <error> <errorno>BL01001973</errorno> <description /> <description2>Error While Saving the Project info</description2> <correction /> </error> <error> <errorno>Unable to Create Custom...

Python - Selenium and XPATH to extract all rows from a table

python,selenium,xpath,selenium-webdriver,web-scraping
I am using Selenium and XPATH to extract all rows from a table, but can only get the first row. Here is what I am doing: from selenium import webdriver path_to_chromedriver = '/Users/me/Desktop/chromedriver' browser = webdriver.Chrome(executable_path = path_to_chromedriver) url = "http://www.psacard.com/smrpriceguide/SetDetail.aspx?SMRSetID=1055" browser.get(url) browser.implicitly_wait(10) SMRtable = browser.find_element_by_xpath('//*[@class="set-detail-table"]/tbody') for i in SMRtable.find_element_by_xpath('.//tr'):...

Unable to select column with its header through XPath

xpath
My HTML <table id="flex1" cellspacing="0" cellpadding="0" border="0"> <thead> <tr class="hDiv"> <th width="6%"> <div class="text-left field-sorting asc" rel="IFSC_CODE"> IFSC CODE </div> </th> <th width="6%"> <div class="text-left field-sorting " rel="BRANCH_NAME"> BRANCH NAME </div> </th> </tr> </thead> <tbody> <tr> <td class="sorted" width="6%"> <div class="text-left">SACS011151</div> </td> <td width="6%"> <div...

Scraping with Nokogiri::HTML - Can't get text from XPATH

html,ruby,parsing,xpath,nokogiri
I'm trying to scrape html with Nokogiri. This is the html source: <span id="J_WlAreaInfo" class="wl-areacon"> <span id="J-From">山东济南</span> 至 <span id="J-To"> <span id="J_WlAddressInfo" class="wl-addressinfo" title="全国"> 全国 <s></s> </span> </span> </span> I need to get the following text: 山东济南 Checked shortest XPATH with firebug: //*[@id="J-From"] Here is my ruby code: doc =...

How to remove the line breaks in front of a tag in Xpath

python,xpath
So here is my HTML code: </div><div id="structureDescs" class="buttonWrap"><h2>Structure Descriptors</h2> <div><h3>InChI</h3> 1S/C2H4O/c1-2-3/h2H,1H3<br> <button type="button" id="downloadInchi">Download</button> </div> <div><h3>InChIKey</h3> IKHGUXGNUITLKF-UHFFFAOYSA-N<br> <button type="button" id="googleInchi">Search the web for this InChIKey</button> </div> <div...

XPath query to select nodes

c#,xml,xpath,xmlnodelist
I have the following XML: <?xml version="1.0" encoding="utf-8"?> <Persons> <Person> <PersonID>6352</PersonID> <Forename>Tristan</Forename> </Person> <Person> <PersonID>6353</PersonID> <Forename>Ruth</Forename> </Person> <Person> <PersonID>6913</PersonID> <Forename>Mina</Forename> <Surname>Asif</Surname> </Person> <Person> <PersonID>6914</PersonID>...

How to Pass Dynamic Values in Xpath

c#,selenium,xpath,selenium-webdriver
This is my First Question in this blog. Am working on Selenium with C# Automation and have hit a road block. I need to click on a Checkbox which is not static and the ID is also not static so i have decided to use XPATH. XML Code: <div id="divJqTreeAPOS"...

XPath - How to get image source from xml

xpath
Hello i have this xml <item> <title> Something for title»</title> <link>some url</link> <description><![CDATA[<div class="feed-description"><div class="feed-image"><img src="pictureUrl.jpg" /></div>text for desc</div>]]></description> <pubDate>Thu, 11 Jun 2015 16:50:16 +0300</pubDate> </item> I try to get the img src with path: //description//div[@class='feed-description']//div[@class='feed-image'][email protected] but it doesn't work is there any...

Difference between ancestor and ancestor-or-self

xslt,selenium,xpath,selenium-webdriver
I know about ancestor in xpath but what is this ancestor-or-self. when we have to use ancestor-or-self.Please give me any examples.

Scrapy xpath construction for tables of data - yielding empty brackets

html,xpath,scrapy
I am attempting to build out xpath constructs for data items I would like to extract from several hundred pages of a site that are all formatted the same. An example site is https://weedmaps.com/dispensaries/cannabicare As can be seen the site has headings and within those headings are rows of item...

XSLT: Copy an attribute from one node to another

xml,xpath,xslt-1.0
I am relatively new to XSLT and i am working on a project involving xml and xslt1.0. I have a xml code (simplified version) that looks like <visualChildren> <object class="com.zerog.ia.installer.InstallSet" > <installChildren> <object class="com.zerog.ia.installer.InstallBundle" objectID="33110emc908m"> <property></property> </object> <object class="com.zerog.ia.installer.InstallBundle" objectID="43110emc9667m"> <property></property> </object> </installChildren>...

xml parsing error (xpath, HTMLagilitypack)

c#,xml,xpath,xml-parsing,html-agility-pack
I am trying to parse an xml. All nodes have opening and closing tags except one node that in some lines in only has this tag: <persons/> In most of the time it appears like this: <persons> ... </persons> I cannot get values from the xml when this node is...

Can I use root-relative XPath expressions to get nodes in a cloned node?

java,xml,xpath
Consider this code, in which we: 1) Build a simple XML document; 2) Clone one of its nodes; 3) Search with xpath for attribute a in node in: @Test public void lookupInClonedNode() throws Exception { String xmlString = "<?xml version=\"1.0\" encoding=\"utf-8\"?><out a='1'><in a='2'/></out>"; Document document = DocumentBuilderFactory .newInstance() .newDocumentBuilder() .parse(new...

Selection skipping node on missing childnode

xpath,vbscript,xml-parsing
Here is my XML file: <?xml version="1.0" encoding="iso-8859-1" ?> <data> <metadata> <sector>weather</sector> <title>sourceTitle</title> </metadata> <weather> <countries> <country code="AU" name="Australia" region="Oceania"> <location type="APLOC" code="6700" name="Addington" state="VIC" postcode="3352"> <point_forecasts type="TWC"> <related_location type="TWCID" code="9508" name="Ballarat" state="VIC"> </related_location> <point_forecast...

Python Web Scraping title in a special div & Page 1 + 15

python,css,xpath,web-scraping,request
Hey guys following problem. I want to scrap data from a website. But there are 2 issues: I have setup to check pricing. That works very well but it does only work for page 1 and 15. But I want all from 1-15 like 1,2,3,4,5 etc. I have the problem...

Java Selenium - Can't seem to select an element

java,selenium,xpath,hidden
I'm trying to select an e-mail href to grab the text, but no matter what selections I use to try to select the e-mail, my selection doesn't seem to work and I am curious what other ways might exist to fix the problem. I have used absolute and relative xpath,...

xslt condition output one by one

xml,function,xslt,if-statement,xpath
hope that someone has a suggestion about this: I need to have in each 'a', all the 'b' that have @n equal or bigger than the @n of the 'a' in which they are. I am using xslt 2.0 and Saxon-HE 9.6.0.5 XML source: <blabla> <a n="2"></a> <a n="6"></a> <b...

Pulling one value by specifying another

xml,xpath
For the following XML snippet - <response uri="http://campaigns.zoho.com/api/recentsentcampaigns" version="1"> <status>success</status> <code>0</code> <recent-sent-campaigns> <campaign no="1"> <fl val="campaign_key">somekeyvalue</fl> <fl val="sent_date_string">08 Jun 2015, 11:55 PM</fl> <fl val="sent_time">1433850936000</fl> <fl val="campaign_name">Test for Mailing List</fl> <fl val="created_date_string">08 Jun 2015, 10:38...

Using XPath to select the href attribute of the following-sibling

html,google-chrome,xpath,web-scraping
I am attempting to scrape the following site: http://www.hudson211.org/zf/profile/service/id/659837 I am trying to select the href next to the "web address" text. The following xpath selector gets the tag I am after: $x("//th[contains(text(), 'Web Address')]/following-sibling::td/a") returns <a href="http://www.co.sullivan.ny.us">www.co.sullivan.ny.us</a> However, when I specifically try to extract the href using @href, the...

Load just XPath search to XMLReader memory?

php,xpath,simplexml,xmlreader
Can i somehow do this? XMLReader is pull parser, so i expect from him to give me just data i search, but it loads whole document into memory and then gives me search from his memory. This code: $url = $this->buildUrl($name,$params); $xml = ''; $reader = new XMLReader(); $reader->open($url); $pathXML...

Traversing with XPath?

html,css,xpath,traversal
I am looking for a faster way to grab contents with xpath. I read this post: Selecting a css class with xpath put the first responses "class" selector in my project, as.. //*[contains(concat(" ", normalize-space(@class), " "), " attr-price ")] which works great. It returns to me all the elements...

What version of XPath does XmlDocument.SelectSingleNode use?

c#,.net,xml,xpath
I'm using the XmlDocument class like this: divisionsDoc.SelectSingleNode( string.Format(@"Root/PoliticalDivisions/PoliticalDivision[upper-case(@Code)='{0}']", withCode.ToUpper())); And this is resulting in the error: Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function. I gather this is due to the upper-case XPath function, which I understand exists in XPath 2.0 and not...

Remove Duplicate XML Records

c#,linq,xpath
I wanted to remove duplicate records in my xml but so far unable to I am unsure of how I can go about doing this, here is the xml and you can see there are 4 duplicate records. I want to remove itemGrp node due to having same rateClass element...

How to remove nodes above and below somewhere in the document

c#,html,xpath,html-agility-pack
Assuming I have an instance of HtmlNode pointing to table, how can I remove all nodes above and below it? we can assume table is in the same level of html and body tag <html> <body> <p>please remove me</p> <table> .... </table> <p>please remove me</p> <a> ... </a> . <img>...</img>...

XPath expression using “and” doesn't work in Microsoft Edge?

xml,xpath,microsoft-edge
I'm working on an application that uses XPath expressions to select nodes from XML. We've noticed that this seems to break down for us when testing in the Microsoft Edge preview. I've cut down our code to a brief snippet that demonstrates the issue: var xml = "<xml id='relationships'><Relationships><f id='some_id'...

Unable to select text boxes in selenium webdriver through XPath?

selenium,xpath
My HTML <table border="2" style="background:gray"> <tbody> <td class="std"> <input id="ActQ1Revenue" type="text" name="amount" disabled="disabled" maxlength="20" style="background:wheat"> </td> </tr> <tr> <td class="atd"> <input id="ActAprRevenue" type="text" name="amount" maxlength="20"> </td> </tr> <tr> <td class="atd"> <input id="ActMayRevenue" type="text" name="amount" maxlength="20"> </td> </tbody> </table> My XPath...

Adding a child attribute to the parent element in xslt 1.0

xml,xslt,xpath,xslt-1.0
I have multiple elements that contain an uniqueId(generated and stored in a variable). I have recursively added the element(object class=Bundle with unique id ) with the xsl as follows <xsl:template match="visualChildren"> <object class="Set" > <installChildren> <xsl:call-template name="Bundle"> <xsl:with-param name="i" select="1"/> <xsl:with-param name="limit" select="4" /> </xsl:call-template> </installChildren> </object> </xsl:template> <xsl:template name="Bundle">...

group siblings by identifying the first node of a certain type in sequence

xml,xslt,xpath
Not sure if that description is the best...but given this xml: <?xml version="1.0"?> <root> <type1 num="1" first="1"/> <type1 num="2" /> <type2 num="3" /> <type2 num="4" /> <type1 num="5" first="2"/> <type1 num="6" /> <type2 num="7" /> <type2 num="8" /> <type1 num="9" first="3"/> <type1 num="10" /> <type2 num="11" /> <type2 num="12" />...

Using xpath to locate element with an underline in the name

xpath,selenium-webdriver,unique
I am trying to click on a webelement that changes ID and xpath dynamically. I dont see any other information that can be used directly to identify the element uniquely everytime the page loads. Here is the Xpath for the element: .//*[@id='isc_SB']/table/tbody/tr/td This will be updated along with ID at...

XQuery: Select a node in the context of a varaible

xpath,xquery,basex
In order to learn XQuery I tried to run the following XQuery command in BaseX let $x := doc("test.xq")//h2/following-sibling return $x::h2 I supposed it should be equivalent to let $x := doc("test.xq")//h2/following-sibling::h2 return $x But it gives the following error and doesn't work while the second command works Error: Stopped...

XPath does not work with XMLReader and SimpleXML? [duplicate]

php,xml,xpath,simplexml,xmlreader
This question already has an answer here: Load just XPath search to XMLReader memory? 1 answer I get feeds from an xml feeder and his XML structure is like this: <XMLSOCCER.COM> <OddsList> <Odds> <FixtureMatch_Id>346076</FixtureMatch_Id> <Bookmaker>Bet-At-Home</Bookmaker> <UpdatedDate>2015-06-20T19:42:32.943</UpdatedDate> <Type>Over/Under 2.5</Type> <HomeOdds>2.22</HomeOdds> <AwayOdds>1.58</AwayOdds> </Odds> <Odds>...

XML-XSLT-XPATH : How to convert multiple XML elements to a string, separated by semicolon

xml,xslt,xpath,xslt-2.0
I have just demonstrated my question as an input and output format as below. I have an input as xml document which consist of following data <Users> <user> <name>Mark Curtain</name> <email>[email protected]</email> <username>mark</username> </user> <user> <name>Zuke Gossip</name> <email>[email protected]</email> <username>zuke</username> </user> <user> <name>Villan Kiosk</name> <email>[email protected]</email>...

Can't get value from xpath python

python,html,xpath,web-scraping,html-parsing
I want to get values from page: http://www.tabele-kalorii.pl/kalorie,Actimel-cytryna-miod-Danone.html I can get all values from first section, but I can't get values from table "Wartości odżywcze" I use this xpath: ''.join(tree2.xpath("//html/body/div[1]/div[3]/article/div[2]/div/div[4]/div[3]/div/div[1]/div[3]/table[1]/tr[3]/td[2]/span/text()")) But I'm not getting anything. With xpath like this: ''.join(tree2.xpath("//html/body/div[1]/div[3]/article/div[2]/div/div[4]/div[3]/div/div[1]/div[3]/table[1]/tr[3]/td[2]//text()")) I'm...

How to select the specific element using HtmlUnit with java?

java,gwt,xpath,htmlunit
I am using Java+HtmlUnit to test my Java-GWT project. I have an element like this: <span unselectable="on" class="x-tree3-node-text">OCP</span> in the source code of my generated html page. How can I select it using XPath (or with any another method)? I've found something like this from documentation about how to use...

selenium xpath unable svg element

html,selenium,xpath
I am working on a web page which consists of 6 svg tags i have to verify each svg in that one is like the following one there are totally 26 paths in this i have to locate the 18th one html is like this <div> <svg> <circle r="80" cy="80"...

How can I find a node containing a sub-string?

xml,xpath,vbscript,asp-classic
I am able to find nodes in an XML file using the following statement: Set user = objXMLDoc.selectSingleNode("//user[@id = '" & id & "']") But the XML files I'm reading are being generated automatically and sometimes contain spaces after the ID. The id attribute of the user node might look...

Combine multiple tags with lxml

python,html,xpath,lxml
I have an html file which looks like: ... <p> <strong>This is </strong> <strong>a lin</strong> <strong>e which I want to </strong> <strong>join.</strong> </p> <p> 2. <strong>But do not </strong> <strong>touch this</strong> <em>Maybe some other tags as well.</em> bla bla blah... </p> ... What I need is, if all the tags...

Stuck scraping a specific table with scrapy

python,xpath,scrapy
So the table I'm trying to scrape can be found here: http://www.betdistrict.com/tipsters I'm after the table titled 'June Stats'. Here's my spider: from __future__ import division from decimal import * import scrapy import urlparse from ttscrape.items import TtscrapeItem class BetdistrictSpider(scrapy.Spider): name = "betdistrict" allowed_domains = ["betdistrict.com"] start_urls = ["http://www.betdistrict.com/tipsters"] def...

Count unique values in comma separated value in xslt 1.0

xpath,xslt-1.0
I have an node in an XML file: <TEST_STRING>12,13,12,14</TEST_STRING> I need to count how many unique numbers/values this string has. For example, in this case there are 2 unique values i.e. 13 and 14. Honestly speaking i could not build anything yet. It seems it is difficult in XSLT 1.0...

XPath query: parsing multiple paths using the same query (Cross Apply / .nodes() )

sql-server,xml,tsql,xpath
I have a rather big and structured XML receipt which one I want to parse into a relational database. There are some equal structures on different levels, so it'd be very good to parse them using the same SQL statement. Like: DECLARE @XMLPath varchar(127) SET @XMLPath = 'atag/btag/item' INSERT INTO...

Loop through all nodes in xml and save path & value of nodes

c#,xml,xpath
I have the following xml (see picture) with multiple level of child nodes. I want to get value and full path of each node. I have tried to iterate through all the nodes but the grand child nodes are not comping in the loop. If I run a loop within...

xslt 2.0 group-starting-with by element contents

xml,xslt,xpath,xslt-2.0,xpath-2.0
I'm new to XSLT 2.0 and XPATH 2.0 and I'm struggling to grouping a list of contacts, my intent is to merge adjacent numbers that belongs to the the previous defined person (note the empty elements). here my input XML <rows> <row> <person>John</person> <tel>1111</tel> </row> <row> <person>George</person> <tel>2222</tel> </row> <row>...

How to connect nested xpaths for Selenium webdriver assert? i.e. Label and separate button in a row

java,selenium,xpath,selenium-webdriver
I am attempting to assert that a button on our page is disabled. The below HTML is what I am working with at the moment: <div data-persona-noeditable="" style="display: block;"> <div class="c-potential-tooltip persona-name pull-left" data-potential-tooltip=""> <div data-name-persona="" class="marg5" data-original-title="" title="">autoTestMapped</div> </div> <button class="btn btn-small pull-left marg5" data-copy-persona="">Copy</button> <button class="btn btn-small pull-left...

Transform XML structure using XSLT

xml,xslt,xpath
I want to transform an XML structure with XSLT. <detaileddescription> <para>Some text</para> <para> <bold>Title</bold> </para> <para>Intro text: <itemizedlist> <listitem> <para>Text</para> </listitem> <listitem> <para>Text</para> </listitem> </itemizedlist> </para> </detaileddescription> This is what I want: <detaileddescription> <para>Some text</para> <List>...

How to get the node with min attribute value?

xml,xpath,min,nodelist
My xml structure is something like this : <page height="777" width="777"> <block r="777" l="778" blockType="Text"> <region/> <separator/> </block> <block r="777" l="790" blockType="Text"> <region/> <separator/> </block> <block r="777" l="688" blockType="Text"> <region/> <text/> </block> </page> i want the select the block node which has the min "l" value i.e "688" I know...

Query XPath in Adobe CRX

xpath,crx
I am performing an XPath query in Adobe CRX and I am trying to find a list of nodes that contains the string 'Xbox Live'. What I am getting back are nodes that contain both 'Xbox' and 'Live'. I am wondering what would the query be to get an exact...

Linq in C++ CLI

xml,linq,visual-c++,xpath,c++-cli
I need to get details from a xml file. I wrote code in C# but not able to rewrite in C++/CLI. Code in C# class cROI { public Int16 iX { get; set; } public Int16 iY { get; set; } public Int16 iWidth { get; set; } public Int16...

Python XPath include missing elements

python,xml,xpath,xml-parsing
<tree> <item> <element1>somedata</element1> <element2>moredata</element2> <element3>data?</element3> <optional_element>data!</optional_element> </item> <item> <element1>somedata</element1> <element2>moredata</element2> <element3>data?</element3> </item> <item> <element1>somedata</element1> <element2>moredata</element2> <element3>data?</element3>...

Is there a bug in xpathSApply if you produce your own XML object?

xml,r,xpath
I tried the following: library(XML) top = newXMLNode("A") newXMLNode("b", attrs=c(x=1,y='abc'),parent=top) newXMLNode("c", "With some text", parent=top) top xpathSApply(top,[email protected]') and the R stops working....

What is the xpath for retrieving all attribute nodes (whatever be the attributes name) with a specified value?

java,xml,xpath
Following is a sample xml. <library> <book id="aaa"> <title id="bbb">Harry Potter and the Half Blood Prince</title> <author id="ccc" ref="zzz"/> </book> <book id="ddd"> <title id="eee">Harry Potter and the Philosophers Stone</title> <author id="fff" ref="zzz"/> </book> <author-details id="zzz"> <firstName id="ggg">Joanne</firstName> <lastName id="hhh"/>Rowling</lastName> </author-details> </library> There are many more books in this...

How to use XPath on TXMLDocument which has namespace prefixes?

xml,delphi,soap,xpath
I have an XML packet received from a third-party web server: <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <SomeResponse xmlns="http://someurl"> <SomeResult> ..... </SomeResult> </SomeResponse> </soap:Body> </soap:Envelope> To be cross-platform capable, this XML is loaded into Delphi's IXMLDocument:...

Appium xpath escaping apostrophes

java,selenium,xpath,appium,apostrophe
I have the code below in my appium script: public boolean isErrorDisplayedUnrecognisedLoginCredentials() { return appDriver.isElementExist(By.xpath("//UIAStaticText[@name='We don't recognize this user ID or password']")); } The test is hanging since it treats the apostrophe in "don't" as a final apostrophe to close off the @name value. I have tried escaping the apostrophe...