If I were to argument in favor of the observed behavior I would cite the XPath specification: A / by itself selects the root node of the document containing the context node. But in DOM, a cloned node does not have a parent and is consequently not contained in...
XPath cannot modify an XML file. For that you need XSLT or XQuery. If this really is a global change (that is, if you want to change this text regardless of the context where it appears) then I would be very inclined myself to do it using a text editor:...
firefox,xpath,selenium-webdriver,selenium-ide,robotframework
You can use this. This would select the anchor descendants of section and get you the second node. This works with xslt processor, hope this works with Selenium //section[@id='mysection']/descendant::a[2] ...
python,html,xpath,web-scraping,html-parsing
The values in the table are generated with the help of javascript being executed in the browser. One option to approach it is to automate a browser via selenium, e.g. a headless PhantomJS: >>> from selenium import webdriver >>> >>> driver = webdriver.PhantomJS() >>> driver.get("http://www.tabele-kalorii.pl/kalorie,Actimel-cytryna-miod-Danone.html") >>> >>> table = driver.find_element_by_xpath(u"//table[tbody/tr/td/h3...
c#,xml,xpath,xml-parsing,html-agility-pack
why are you using htmlnode? xmlnode would be just fine. Or else, show more codes. Did you step through the line? Did you encounter any error? try this: internal string ParseXML() { string ppl = ""; XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlString); foreach (XmlElement node in doc.SelectNodes(".//person")) { string text...
html,xml,xpath,selenium-webdriver,web-scraping
You can select a table cell whose contents equals a string such as "Item Pricing" via the following XPath: //td[. = 'Item Pricing'] ...
After days of research i got the solution for accessing the svg elements xpath for traversing to a particular element .//*[@id='global-wrapper']/div[1]/main/div/div[2]/div[3]/div[1]/ol/li[1]/article/div/div/div/div/div[1]/div/*[name()='svg']/*[name()='path' and @fill='#aec7e8'] add a unique attribute to access the element in my case the it was fill color ...
Do you get any exceptions thrown? if the element is not visible then a NoSuchElementException will be thrown. Other then that, i would suggest making your xpath more readable, something like the following: String emailAddress = driver.findElement(By.xpath("//span[@class='email']")).getText(); ...
xml,spring,unit-testing,xpath,spring-test
No, it's not possible to reuse XpathResultMatchers without MockMvc and related classes. However... the code in question (in your pseudo-code example), delegates internally to Spring's XpathExpectationsHelper. So you can invoke -- for example -- the exists() method directly on an instance of XpathExpectationsHelper if you so desire. As an alternative,...
You are still searching the entire OddsList. Try using the XMLReader something like this: $reader = new XMLReader(); $reader->open($url); $dom = new DomDocument(); // Find first occurrence of Odds while ($reader->read() && $reader->name !== 'Odds'); // Iterate Odds while ($reader->name === 'Odds'){ $odds = simplexml_import_dom($dom->importNode($reader->expand(), true)); // Process those having...
You can simply use xpath union operator (|) to combine two xpath queries, for example* : //table/tbody/tr/td[count(//table/thead/tr/th[.='BRANCH NAME']/preceding-sibling::th)+4] | //table/thead/tr/th[.='BRANCH NAME'] *: formatted into multiple lines just to make it visible without horizontal scroll...
Change expression so //input[@type='text' and not(@disabled ='disabled')] ...
It's difficult to provide an answer without seeing the input. I believe you need to do something like the following: XSLT 1.0 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="visualChildren"> <xsl:variable name="bundles"> <xsl:call-template name="create-bundles"> <xsl:with-param name="n" select="4" />...
Try with: list( chain( *list( { e : 1 for e in list(zip_longest(*([iter(tr)] * 2), fillvalue=''))}.keys() ))) It creates an iterable over the same list duplicated, so it mixes elements of both. Then I use a dictionary comprehension to remove duplicated tuples generated from zip_longest(). chain flattens values inside tuples...
As Arthur Elrich pointed out in the comments, you should make the factory namespace aware and provide a namespace context to the XPath instance. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse( new InputSource(new StringReader(...))); XPath xpath = XPathFactory.newInstance().newXPath(); xpath.setNamespaceContext(new MyNamespaceContext()); String s = xpath.evaluate("//location:address/text()",...
seems like your xpath has some problem, checkout the demo from scrapy shell, In [1]: response.xpath('//tr[td[@class="mainheaderq" and contains(font/text(), "ANSWER")]]/following-sibling::tr/td[@class="griditemq"]//text()').extract() Out[1]: [u'\r\n\r\n', u'MINISTER OF STATE(I/C) FOR COAL, POWER AND NEW & RENEWABLE ENERGY (SHRI PIYUSH GOYAL)\r\n\r\n ', u'(a) & (b): So far 29 coal mines have been auctioned under the provisions...
javascript,css,ruby,xpath,nokogiri
Simpler is just: doc.search('style,script').remove ...
This is one possible way : $start_nodes = $finder->query('//div[p/@class="start"]'); foreach ($start_nodes as $node) { $count = $finder->evaluate('count(preceding-sibling::div[p/@class="start"])', $node)+1; echo 'start '. $count .' : <br>'; $start = 'self::*'; $end = 'following-sibling::div[p/@class="end"][1]'; $inbetween = 'following-sibling::div[p/@class="end"][1]/preceding-sibling::*[count(preceding-sibling::div[p/@class="start"])='.$count.']'; $data_nodes = $finder->query($start.' | '.$inbetween.' | '.$end, $node);...
How about this: //Time[text() = '...']/@hours ...
It's possible without nodesets. It's not optimal, of course (hello, Shlemiel The Painter), but it's pretty easy - increment counter only if there is no given string ahead or behind. Template <xsl:template name="calcUnique"> <xsl:param name="str"/> <xsl:param name="back"/> <xsl:param name="count"/> <xsl:if test="$str"> <xsl:choose> <xsl:when test="contains($str, ',')"> <xsl:variable name="part" select="substring-before($str, ',')"/> <xsl:call-template...
When you say name = sel.xpath('td[@class="tipst"]/a/text()').extract()[0] the XPath expression starts with td and so is relative to the context node that you have in the variable sel (i.e. the tr element in the set of tr elements that the for loop iterates over). However when you say name = sel.xpath('//td[@class="tipst"]/a/text()').extract()[0]...
$str = '<root><Pages> <copyright>me inc. 2015,</copyright> <author>Me</author> <lastUpdate>2/1/1999</lastUpdate> <Home>--------------------</Home> <About>--------------------</About> <Contact>------------------</Contact> </Pages></root>'; $xml = simplexml_load_string($str); $result = $xml->xpath('//Pages/*[(name() = "Home") or following-sibling::Home]'); if ($result === false) { $this->parseError(); //To return xml Error code...
php,xpath,input,hidden,nodevalue
this is your code using DOM xpath : $html='<input type="hidden" id="Lat" name="myMap" value="22.445575, -18.722164">'; $doc = new DOMDocument; $doc->loadHTML($html); $xpath = new DOMXpath($doc); $val= $xpath->query('//input[@type="hidden" and @name = "myMap"]/@value' ); $list=array(); foreach($val as $v){ $list[]=$v->nodeValue; } var_dump($list); ...
Well //@* gives you all attribute nodes, add a predicate //@*[. = 'zzz'] and you have all attribute nodes with the value zzz.
symfony2,xpath,behat,mink,symfony-2.7
The solution in the end was to make sure the format_listener had the correct rules by added a fallback / rule. This will mean all non /api requests will be html. fos_rest: disable_csrf_role: ROLE_API routing_loader: default_format: json, include_format: true body_listener: true param_fetcher_listener: force format_listener: rules: - path: '^/api' priorities: ['json',...
You can try with itertext() method, that iterates over all text content: from lxml import etree root = etree.XML('<root><div>abc</div><div>def</div></root>') print(' '.join(e for e in root.itertext())) It yields: abc def ...
If you want to use conditions on nodes then I would suggest to put them into match patterns: <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="detaileddescription/para[bold][following-sibling::*[1][self::para[.//para]]]"> <List> <Title>...
You need to, first, define mapping of namespace prefix to namespace uri, before you can use the prefix in your xpath. In this case, use XmlNamespaceManager to define the mapping, then you can simply pass the namespace manager instance as 2nd parameter of SelectNodes() : : ...... var nsManager =...
//div[contains(concat(' ',@class,' '), ' A ')]//div[contains(concat(' ',@class,' '), ' B ')][1] ...
Using lxml and tail property (text that directly follows the element) of the element. >>> import lxml.html >>> >>> a = "<b>AAA:</b> BBB<br/><br/><img src='line.gif' /><br/><br/><b><font size='2'>Text: </b>WahtIwant</font><br/><center>" >>> root = lxml.html.fromstring(a) >>> [x.tail for x in root.xpath('//font[@size="2"]/parent::b')] ['WahtIwant'] ...
You can use xpath union operator (|) to combine multiple xpath expressions, f.e one to handle the case when tbody exists, and another for the case when tbody doesn't exist : //table[@id='Main']/tbody/tr | //table[@id='Main']/tr ...
You can use the following XPath : //Person[not(Surname)] ...
xml,xslt,xpath,xslt-2.0,xpath-2.0
You need to match on group-starting-with="row[normalize-space(person)]" <xsl:template match="/"> <contacts> <xsl:for-each-group select="rows/row" group-starting-with="row[normalize-space(person)]"> <contact> <xsl:copy-of select="person"/> <numbers> <xsl:copy-of select="current-group()/tel"/> </numbers> </contact> </xsl:for-each-group> </contacts> </xsl:template> ...
There is no way you can construct XQuery parameter dynamically as it is limited to literal string only. See what MSDN says about the parameter of nodes() XML method : XQuery Is a string literal, an XQuery expression. If the query expression constructs nodes, these constructed nodes are exposed in...
java,selenium,xpath,appium,apostrophe
AFAIK, you can't escape quotes in xpath, but you can escape quotes in Java. So try to use escaped double quotes for the xpath literal string delimiter, for example : By.xpath("//UIAStaticText[@name=\"We don't recognize this user ID or password\"]") ...
you could use something like: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:text>UserNames: "</xsl:text> <xsl:value-of select="/Users/user/username" separator=";"/> <xsl:text>"
</xsl:text> <xsl:text>Names: "</xsl:text> <xsl:value-of select="/Users/user/name" separator=";"/>...
Shouldn't you be using: river.FindElement(By.XPath("//td[4]/a")).Click(); ? And if you have similiar Problems. You can use the Console in the developer tools of Chrome and write like this: $x("YOUR XPATH HERE") This will result in your element. If that's not the case, then your Xpath is wrong. Edit: If you want...
I have managed to solve my own problem. for p in self.tree.xpath('//body/p'): if p.tail is None: # some conditions specifically for my doc children = p.getchildren() if len(children)>1: for child in children: #if other stuffs present, break if child.tag!='strong' or child.tail is not None: break else: # If not break,...
The XPath equivalent to $('ul').find(...) would be //ul//... So your XPath would become //ul//*[contains(concat(" ", normalize-space(@class), " "), " attr-price ")] Whether that is actually any faster depends on the XPath processor and the DOM model implementation, I guess. On a different note, your compound selector //*[contains(concat(" ", normalize-space(@class), "...
Dynamic evaluation (treating a string in a variable as an XPath expression and evaluating it) is available as a vendor extension in a number of XSLT processors, and it becomes part of the standard with the introduction of xsl:evaluate in XSLT 3.0. If your XSLT processor doesn't have such an...
Simply use: //tr[td = 'PQR']/td/button Or, if you want to use contains(), then: //tr[td[contains(.,'PQR')]]/td/button ...
This appears to be a bug with the current implementation in Microsoft Edge. I did notice, however, that if you flip the conditions around, the proper element is retrieved: //f[f and @id='some_id'] For the time being, I hope this is an acceptable alternative. I am opening up a bug for...
Call this method before passing the value to the Locator. method_name(){ Actions actionObj = new Actions(driver); actionObj.keyDown(Keys.CONTROL) .sendKeys(Keys.chord("A")) .keyUp(Keys.CONTROL).keyUp(keys.DELETE) .perform(); } findElement By xpath add a condition like getText()!="" and then It will be done. Is it working??...
SQL Server does not implement the xPath function string-join, so you would need to adopt a two step process, the first would be to extract all the terms to rows using nodes(); SELECT n.value('.', 'VARCHAR(100)') AS parsedString FROM #temp AS t CROSS APPLY t.Response.nodes('/error/description2') r (n); Which gives you your...
You're trying to iterate an element directly, you'd need to iterate its descendant field elements, so instead of: foreach (var field in list) You want: foreach (var field in list.Descendants("field")) That said, an easier way of doing this is to make use of LINQ: var urls = xmlDoc.Descendants("list") .Where(e =>...
[...] to extract elements between two succeeding headings [...] You need something more like: for $x in doc("test.xq")//h2 return $x/following-sibling::*[preceding-sibling::h2[1] is $x] but on its own it won't give you anything useful because the XPath and XQuery data model only has flat sequences, not "multi-dimensional arrays". When you have...
The code you posted can't possibly work with the XML you posted. There is no method SelectSingleNodes. It's either SelectNodes or SelectSingleNode. The <uv> nodes are immediate children of the <point_forecast> nodes. An XPath expression */uv would match grandchildren (like with */point_forecast). The attribute index is not the text (content)...
Your xpath is too verbose, having full path and element indexes it is not intuitive to read and tends to break due to slight changes in the page source. Try using the following simpler xpath : //*[@id="wrapper"]//div[@class='col-md-12']//h5/b It worked for me to get all Steam ID's and character names (total...
It is important to inspect the string returned by page.text and not just rely on the page source as returned by your Chrome browser. Web sites can return different content depending on the User-Agent, and moreover, GUI browsers such as your Chrome browser may change the content by executing JavaScript...
This is definitely a bug. Note that , this works fine: xpathSApply(top,'//A/b') ## without attribute As a workaround, you can get the attribute using xmlGetAttr: xpathSApply(top,"//A/b",xmlGetAttr,"x") ...
You are passing a String: ClickByXpath(driver, "/html/body/div/div[3]/form/div[2]/div[2]/div[1]/div[1]/div[3]/div/div[3]/div/input[1]"); But you method signature says that you should pass a String Array: public static void ClickByXpath(WebDriver [] driverUsed , String[] XPath_to_click) Same problem with your driver! If you change the signature and remove the Arrays, you should be good: public static void ClickByXpath(WebDriver...
UPDATE 2: According to the updated XML sample, assuming that you want to find minimum value of l attribute of line element, try this way : //page/block/text/par/line[not(preceding::line/@l <= @l) and not(following::line/@l<@l)]/@l output : Attribute='l="253"' UPDATE : Actually, by having combination of preceding-sibling::block/@l <= @l and following-sibling::block/@l < @l, there is...
java,selenium,xpath,selenium-webdriver
following-sibling would be helpful here: //div[contains(@class, "persona-name") and div = "autoTestMapped"]/following-sibling::button[. = "Deactivate"] ...
The thing is that what you see in your browser is after Javascript has formatted stuff, presumably Angular. If you run the HTML source in a HTML source beautifier, and search for <span class="item_name"> you'll see a pattern like this, repeating blocks of <div class="menu_item" data-category-id="1" data-category-name="Indica" data-json="{}" id="menu_item_5390083" style="position:...
html,ruby,parsing,xpath,nokogiri
However, it returns nothing. What am I doing wrong? xpath() returns an array containing the matches (it's actually called a NodeSet): require 'nokogiri' html = %q{ <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> } doc = Nokogiri::HTML(html) target_tags =...
XQuery does not know such macros, you could of course use any preprocessor to do such things. But I'd rather define a function for this: declare function local:outward($context as item()) { $context/ancestor-or-self::* }; Functions can also be applied in axis steps (remember to pass the current context .): let $xml...
I would use findtext() and specify the default: [item.findtext("optional_element", default="") for item in tree.findall("item")] Demo (using lxml): >>> from lxml import etree >>> >>> data = """<?xml version="1.0" encoding="utf-8"?> ... <tree> ... <item> ... <element1>somedata</element1> ... <element2>moredata</element2> ... <element3>data?</element3> ... <optional_element>data!</optional_element> ... </item> ... <item> ......
xml,xpath,xml-parsing,attributes,parent-node
Ahh,i found this. int separatorDistanceFromRight = Integer.parseInt(separatorNodeList.item(i).getParentNode().getAttributes().getNamedItem("r").getNodeValue()); ...
java,html,xpath,selenium-webdriver
This is sunday //span[contains(.,'Consis')]/parent::td/following-sibling::td/span[contains(.,'Sun')]/text()[1] respectively, [2] is monday Below part, containing sunday //span[contains(.,'Consis')]/parent::td/following-sibling::td/span/text()[contains(.,'Sun')] ...
You are looking for a div element instead of span. Change your xpath to this: //span[@class='x-tree3-node-text'] Furthermore if you want to find an element by its value use this xpath: //span[text()="OCP"] ...
python,xpath,web-scraping,scrapy,scrapy-spider
First of all, your XPath expressions are very fragile in general. The main problem with your approach is that site does not contain a review section, but it should. In other words, you are not iterating over review blocks on a page. Also, the model name should be extracted outside...
python,xpath,web-scraping,scrapy
Wow, I feel stupid. The answer just came to me. I forgot to call .extract() on the temp variable in the parse function of my spider class.
I have been able to come up with a solution for you by writing this code: string file = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "xml.txt"); var xmlDoc = new XmlDocument(); xmlDoc.LoadXml(file); var el = xmlDoc.SelectSingleNode("/Fare_1"); var c = el.ChildNodes; List<string> rateClassValues = new List<string>(); foreach (XmlNode x in c) { foreach(XmlNode ch in...
Microsoft never implemented XPath 2.0 or Xslt 2.0... See for example this uservoice (aptly named Native support for XPath 2.0 or XSLT 2.0 in .NET) of 2013... Last comment of March 2015 by one user: i guess we will never see this as the world doesn't like XML anymore, it's...
That's not how variables work I'm afraid. It looks like you're trying to treat the variable declaration as a kind of "macro" and expecting its textual definition to be substituted in when the variable is referenced, but in fact XQuery variables are more like local variables in C or Java...
Your xpath/xquery is fine, that should return elements containing exact phrase "Xbox Live", assuming Adobe CRX has decent xpath 1.0 implementation. Possible catch is, by using . in contains() concatenation of all descendant text nodes will be evaluated. For example, the following parent element also considered matched the contains(., 'Xbox...
My guess is that you make a mistake while processing the result NodeList. Try the following approach: NodeList results = (NodeList) xpath.evaluate(..); for (int i = 0; i < nodelist.getLength(); i++) { Node node = (Node) nodelist.item(i); ... } ...
Try it this way: <xsl:key name="kFirstText" match="*[not(self::type1[not(preceding-sibling::*[1][self::type1])])]" use="generate-id(preceding-sibling::type1[not(preceding-sibling::*[1][self::type1])][1])"/> This excludes the "leader" nodes from the group retrieved by the key....
All Person tags that has not Person tag with the same PersonID before //Person[not(PersonID = preceding::Person/PersonID)] it gives you nodes Person with children. In this case 4 elements: Element='<Person> <PersonID>6352</PersonID> <Forename>Tristan</Forename> </Person>' Element='<Person> <PersonID>6353</PersonID> <Forename>Ruth</Forename> </Person>' Element='<Person> <PersonID>6913</PersonID> <Forename>Mina</Forename>...
You can try something like this : $xpath->query('//form['.$i.']/preceding-sibling::*[self::h2 or self::h3][1]') basically, the xpath get the first preceding sibling of form[i] that is of type <h2> or <h3> (or whatever, just list all other elements as needed in the xpath predicate)....
c#,xml,xpath,xmldocument,xmlnodelist
If you're happy to convert it into LINQ to XML, it's really simple: XDocument original = ...; // However you load the original document // Separated out for clarity - could be inlined, of course string xpath = "//Person[not(PersonID = following::Person/PersonID)]" XDocument people = new XDocument( new XElement("Persons", original.XPathSelectElements(xpath) )...
Assuming that <big><b>Staff in:</b></big> is a unique element that we can use as 'anchor', you can try this way : //big[b='Staff in:']/following-sibling::a[preceding-sibling::big[1][b='Staff in:']] Basically, the xpath finds all <a> that is following sibling of the 'anchor' <big> element mentioned above, and restrict the result to those having nearest preceding sibling...
selenium,xpath,unicode,selenium-webdriver,webdriver
Am I missing something here? Yes, I think so: <div class="menuitem-content">Français</div> the "a" is missing driver.findelement(By.XPath("//div[text()='Françis']")); EDIT: At least in a Java environment Webdriver can handle Unicode. this works for me (driver in this case being an instance of FirefoxDriver): driver.get("https://fr.wikipedia.org/wiki/Mot%C3%B6rhead"); WebElement we = driver.findElement(By.xpath("//h1[contains(., Motörhead)]")); System.out.println(driver.getTitle() + "...
xml,xpath,vbscript,asp-classic
You can use contains(): Set user = objXMLDoc.selectSingleNode("//user[contains(@id,'" & id & "')]") or if spaces appear only at the end of string you can use starts-with(): Set user = objXMLDoc.selectSingleNode("//user[starts-with(@id,'" & id & "')]") ...
To retrieve a campaign key based on its name, use /response/recent-sent-campaigns/campaign[fl[@val = 'campaign_name'] = 'Test for Mailing List']/fl[@val = 'campaign_key'] which means /response select the `response` element /recent-sent-campaigns select its children `recent-sent-campaigns` /campaign select its children `campagin` [fl[@val = 'campaign_name'] but only if there is a child element called `fl`...
c#,html,xpath,html-agility-pack
According to your HTML sample (and commonly it is), <table> is child of <body>, they are not at the same level. Assuming that table is a variable of type HtmlNode pointing to the <table> element, you can do this way : var nodes = table.SelectNodes("following-sibling::*[1] | preceding-sibling::*[1]"); foreach (HtmlNode node...
xpath,selenium-webdriver,unique
In XPath the string value of an element node is defined as the concatenation of all its descendant text nodes, so if you have a <td>Pu<u>b</u>lish</td> then you can match it using simply //td[. = 'Publish'] If, as in your question, there are newlines either side of the u element...
xml,linq,visual-c++,xpath,c++-cli
I was able to rewrite your code in such a way: using namespace System; using namespace System::Collections::Generic; using namespace System::Xml::Linq; using namespace System::Xml::XPath; ref class cROI { public: property int iX ; property int iY ; property int iWidth ; property int iHeight; cROI (int piX, int piY,int piWidth,int piHeight...
xslt,selenium,xpath,selenium-webdriver
Ancestor and Ancestor-or-self are the XPath Axes. An axis is a node-set relative to the current node. The ancestor axis selects all the ancestors, i.e. parent, grandparent, etc of the current node whereas the ancestor-or-self selects all the ancestors, i.e. parent, grandparent, etc. of the current node and the current...
You can modify the identity transformation to copy over everything exactly except for the visualChildren/object elements, which can be copied over as-is plus the RefId attribute you request: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template...
xml,function,xslt,if-statement,xpath
Try: <xsl:template match="blabla"> <all> <xsl:for-each select="a"> <a n="{@n}"> <xsl:copy-of select="../b[@n >= current()/@n]"/> </a> </xsl:for-each> </all> </xsl:template> ...
A CDATA section escapes its contents. In other words, CDATA prevents its contents from being parsed as markup when the rest of the document is parsed. So the <div>s in there are not seen as XML elements, only as flat text. The <description> element has no element children ... only...
"... but I want to find a player with a given jersey number, and then pull its uID" Then the xpath parameter should look about like this : /Team[@uID='#{team_uid}']//Player[Stat[@Type='jersey_num' and .='#{jersey_num}']]/@uID or maybe without trailing /@uID to get Player element, and then do further extraction from ruby code. Notice...
python,css,xpath,web-scraping,request
Here are the things I would fix/improve: the code is not properly indented, you need to move the HTML-parsing code into the loop body a url whisky.de/shop/Aktuell/1 for the page number 1 would not work, instead don't specify the page number: whisky.de/shop/Aktuell/ to get the prices and titles I would...
You can ignore pretty much all your code, the issue is just this: XDocument people = new XDocument("Persons"); You can't create an XDocument containing a string, you need to add an element: XDocument people = new XDocument( new XElement("Persons", original.XPathSelectElements(xpathFilterDups))); ...
All you need is the identity template to copy existing nodes... <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> Then another template to ignore nodes that aren't lower-case. In XSLT 1.0 this can be done by using the translate statement, to translate uppercase letters to lowercase, and checking if the result...
1) Your template is applied to 3 elements, and for each of them, loops over all the parents li elements (yes, for each of them, ask all the li elements, children of the grand-father of the current content, which are all the 3 li elements, each time). 2) Because that's...
Your xpath is wrong. As I see you try to get the content from the second row/first column (if you doesn't count the headers). Try the following code on http://www.toolsqa.com/automation-practice-table/ page: /html/body/div[2]/div[3]/div[2]/div/div/table/tbody/tr[2]/td[1] or //*[@id='content']/table/tbody/tr[2]/td[1] If you run getText() it will return the following value: Saudi Arabia...
On the Python side, you could use str.strip() to remove whitespace from both sides of the string: In [290]: data = ['\n\t\t\tCC=O'] In [291]: data[0].strip() Out[291]: 'CC=O' or, on the XPath side, you could use normalize-space: In [299]: tree.xpath('normalize-space(//*[text()="Smiles"]/..//br[1]/preceding-sibling::text())') Out[299]: 'CC=O' Note that in addition to removing both leading and...
Assuming that the class name is stored into class_name, I think that doc.xpath("//*[contains(concat(' ', normalize-space(@class), ' '), ' #{class_name} ')]") is what you're looking for. This will match all the elements that contain class_name into their classes, ie if class_name is 'box', then it will match both elements like div...
Your template matches a sec:authentication-provider element: match="bi:realm/sec:authentication-provider[...]" So, within the template, the context node is the matched sec:authentication-provider element. Therefore, when you perform your test, you need to proceed from that context. Your current test test="not(bi:realm/sec:authentication-provider[@xsi:type='ext:session-authenticatorType'])" would only work if the context node were the parent of bi:realm, namely bi:security-configuration....
c#,selenium,xpath,selenium-webdriver
You can use following XPath which will work if Id is dynamic. //webDriver.FindElement(By.XPath("//*[contains(@id,"ChassisId')]/a/ins[contains(text(),'POWER CONNECT')]") ...
By wrapping the <deliveryMethod> elements in a (for example) <deliveryMethodsList> element you can move the unique element so you only have to write it once. As an example you only need to replace your Mailpack complexType with the following: <xs:complexType name="Mailpack"> <xs:sequence> <xs:element name="deliveryMethodsList"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" name="deliveryMethod" type="DeliveryMethod"/>...
php,xml,xpath,simplexml,xmlreader
Your while, seems, not executed even once. Code should read, until needed condition will occur while($reader->read()) { if (reader->nodeType == XMLREADER::ELEMENT && $reader->name == 'XMLSOCCER.COM') ) { $xml = simplexml_import_dom($dom->importNode($reader->expand(),true)); $pathXML = $xml->xpath('//Odds[contains(Bookmaker,"Interwetten")]'); /*if($this->getExpression()){ $xml->xpath($this->getExpression()); }*/ break; } } ...