I have found a node, now i need to select sibling text after it:
In my case i need to get the text : 10 January
How do i do this?
Do note that /html/text() doesn't select all text nodes in the document -- only the text nodes that are children (not descendents) of the top, html element. You probably want /html//text() . Some knowledge and understanding of XPath is typically required in order to construct XPath expressions. Thanks.
XPath text() function is a built-in function of the Selenium web driver that locates items based on their text. It aids in the identification of certain text elements as well as the location of those components within a set of text nodes. The elements that need to be found should be in string format.
XPath stands for XML Path Language. It uses a non-XML syntax to provide a flexible way of addressing (pointing to) different parts of an XML document. It can also be used to test addressed nodes within a document to determine whether they match a pattern or not.
Try this:
//foo/following-sibling::text()[1]
(replace //foo/
with your current XPath expression.
With this XML:
<data> <foo>foo</foo> bar <baz>baz</baz> </data>
it gives bar
as output.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With