I struggle with the following problem:
Have an XPath like so (as you can see quite long):
'//h2[contains(text(),"Kontakt")]/../following-sibling::div[contains(@class,"body") and child::dl[contains(@class,"horizontal")]]'
Now, to make it more readable i tried to split it into multiple lines using Heredoc:
xpath = <<-XPath.gsub(/\s+/,'')
//h2[contains(text(),"Kontakt")]/..
/following-sibling::div[contains(@class,"body") and
child::dl[contains(@class,"horizontal")]]
XPath
The catch, however, is that the .gsub(/\s+/,'')
will remove all whitespaces. I have tried different combinations with just removing \n
or .strip
, but I can't seem to find a solution that outputs the xpath as it is shown above.
Any thougts?