Skip to content Skip to sidebar Skip to footer

Xpath Select All But Not Self::strong And Self::strong/following-sibling::text()

So I have following example html to parse.
Title: Sub Editor at NEWS ABC Name: John <

Solution 1:

I think the following meets what you are trying to do - it excludes the strong element containing title as well as the text node that is after it. You could expand it to include the other strong elements you want to exclude:

//div/node()[not(self::strong and contains(text(), "Title") or preceding-sibling::strong[1][contains(text(), "Title")])]

The strong node is skipped by the:

not(self::strong and contains(text(), "Title")

The following text is skipped by the:

preceding-sibling::strong[1][contains(text(), "Title")]

Note that the text node needs to check its closest preceding sibling (rather than its following sibling).

Post a Comment for "Xpath Select All But Not Self::strong And Self::strong/following-sibling::text()"