2

I'm trying to locate the content from <div class="initiative-section__content">...</div> by using this XPath "//*[contains(text(),'Created')]/following-sibling::*", but it's returning two elements since there is also "Created Date". And I can't figure out how to add "By" to XPath. I tried something like this but it didn't work "//*[contains(text(),'Created') and contains(text(),'By')]/following-sibling::*"

Any ideas?

<div class="initiative-section__title"> "Created" " By" </div> <div class="initiative-section__content">...</div> 

1 Answer 1

2

Test the space-normalized string-value of the div element rather than its children text nodes:

//div[normalize-space() = "Created By"]/following-sibling::* 

Note that you might want to narrow the following sibling test to specify the immediate sibling,

//div[normalize-space() = "Created By"]/following-sibling::*[1] 

or even the first immediate sibling that must be a div element:

//div[normalize-space() = "Created By"]/following-sibling::*[1][self::div] 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.