xpath-1.0

How to pass variable parameter into XPath expression?

孤人 提交于 2019-12-17 03:22:25
问题 I want to pass a parameter into an XPath expression. (//a/b/c[x=?],myParamForXAttribute) Can I do this with XPath 1.0 ? (I tried string-join but it is not there in XPath 1.0) Then how can I do this ? My XML looks like <a> <b> <c> <x>val1</x> <y>abc</y> </c> <c> <x>val2</x> <y>abcd</y> </c> </b> </a> I want to get <y> element value where x element value is val1 I tried //a/b/c[x='val1']/y but it did not work. 回答1: Given that you're using the Axiom XPath library, which in turn uses Jaxen, you

xpath 1.0 list nodes refferring to current node (links counting)

旧城冷巷雨未停 提交于 2019-12-12 05:58:11
问题 What i try to do : I would like to find the proper xpath to count (or list) links referring to the active node. my context is javascript with following detached dom tree used to query xpath with document.evaluate giving a specific entry point. As an example we will consider //*[@id="n11"] as entry point or active node (the second document.evaluate parameter) here the detached dom tree : <root> <node> <a id="n1"/> <a id="n2"/> <a id="n3"/> <a id="n4"/> <a id="n5"/> <a id="n10"/> <a id="n11"/>

Xpath - How to select related cousin data

妖精的绣舞 提交于 2019-12-12 03:56:22
问题 <html> <table border="1"> <tbody> <tr> <td> <table border="1"> <tbody> <tr> <th>aaa</th> <th>bbb</th> <th>ccc</th> <th>ddd</th> <th>eee</th> <th>fff</th> </tr> <tr> <td>111</td> <td>222</td> <td>333</td> <td>444</td> <td>555</td> <td>666</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </html> How can i select specific related cousin data using xpath, The desired output would be be: <th>aaa</th> <th>ccc</th> <th>fff</th> <td>111</td> <td>333</th> <td>666</td> The most important

Time string comparison in XPath 1.0

ε祈祈猫儿з 提交于 2019-12-12 01:57:37
问题 I've got this comparison in XPath1.0: number(substring(translate(translate(translate(@pub-date,'-',''),':',''),' ','') ,5,4)+substring(translate(translate(translate(@pub-date,'-',''),':',''),' ',''),2,3)+substring(translate(translate(translate(@pub-date,'-',''),':',''),' ',''),0,2)+substring(translate(translate(translate(@pub-date,'-',''),':',''),' ',''),9,6)) > number(substring(translate(translate(translate(@pub-date2,'-',''),':',''),' ','') ,5,4)+substring(translate(translate(translate(@pub

selenium - Failed to execute 'evaluate' on 'Document': The string is not a valid XPath expression

人盡茶涼 提交于 2019-12-11 06:27:38
问题 There is the following page. http://remitly.com/us/en/ When you click on a select, a list with countries appears. I try to select one country, for example, Colombia and click on it. But I get an error. SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//span[contains(@class, 'md_countryName_fdxiah8' and text(), 'Colombia')]' is not a valid XPath expression. select = driver.find_element_by_class_name('f1wrnyr7') select.click() countries = driver.find_element_by_class_name(

XPath 1.0: Finding count of nodes before a specified node

馋奶兔 提交于 2019-12-11 03:35:27
问题 I am familiar with using preceding axes in XSLT for finding determining the number of preceding elements given the current context. However, I don't see a way to do the same given a node that I've stored in a variable. For example: <xsl:variable name="matchedBook" select="book[text()='The Hobbit']"/> <xsl:variable name="precedingBookCount" select="count(???)"/> Given the following XML, precedingBookCount should equal 3. <available> <book>Lord of the Rings</book> <book>The Hunger Games</book>

Distinct values with XSLT 1.0 when XPath has multiple criteria

核能气质少年 提交于 2019-12-07 10:53:06
问题 Yet another question about getting distinct values using XSLT 1.0. Here's a stupid, made-up example that should illustrate my problem. <?xml version="1.0" encoding="UTF-8"?> <moviesByYear> <year1994> <movie> <genre>Action</genre> <director>A</director> </movie> </year1994> <year1994> <movie> <genre>Comedy</genre> <director>A</director> </movie> </year1994> <year1994> <movie> <genre>Drama</genre> <director>B</director> </movie> </year1994> <year1994> <movie> <genre>Thriller</genre> <director>C

Xpath to select all and exclude child and its children

ⅰ亾dé卋堺 提交于 2019-12-06 05:55:57
问题 I have the Data below and I am trying to select all the nodes except RejectedRecords and all of its children. <?xml version="1.0" encoding="UTF-8"?> <inmsg> <BPDATA> <DATE_TIME>10072014084945</DATE_TIME> </BPDATA> <Orders> <Rejected> <RejectedRecords> <RecordNumber>1</RecordNumber> <RecordError>State Code is invalid</RecordError> </RejectedRecords> <RejectedRecords> <RecordNumber>2</RecordNumber> <RecordError>State Code is invalid</RecordError> </RejectedRecords> <FileName>Foo1.txt</FileName>

using XPath to select contiguous elements with a certain attribute value

我只是一个虾纸丫 提交于 2019-12-05 11:41:06
I have XML like this: <span>1</span> <span class="x">2</span> <span class="x y">3</span> <span class="x">4</span> <span>5</span> <span class="x">6</span> <span>7</span> <span class="x">8</span> What I want is to use an XSLT stylesheet to put the contents of all elements whose class attribute contains x into one <x> element. So the output should be like this: 1 <x>234</x> 5 <x>6</x> 7 <x>8</x> (or, ideally, 1 <x>2<y>3</y>4</x> 5 <x>6</x> 7 <x>8</x> but that's a problem to tackle when I've solved this one.) This is the relevant fragment of my XSLT: <xsl:template match="span[contains(@class,'x')

Xpath to select all and exclude child and its children

情到浓时终转凉″ 提交于 2019-12-04 11:00:19
I have the Data below and I am trying to select all the nodes except RejectedRecords and all of its children. <?xml version="1.0" encoding="UTF-8"?> <inmsg> <BPDATA> <DATE_TIME>10072014084945</DATE_TIME> </BPDATA> <Orders> <Rejected> <RejectedRecords> <RecordNumber>1</RecordNumber> <RecordError>State Code is invalid</RecordError> </RejectedRecords> <RejectedRecords> <RecordNumber>2</RecordNumber> <RecordError>State Code is invalid</RecordError> </RejectedRecords> <FileName>Foo1.txt</FileName> <MessageType>Rejected</MessageType> <RecordCount>2</RecordCount> <TotalAmount>1050.01</TotalAmount> <