XPath selecting between comments multiple times
问题 We need to read node between HTML comments: <html> <!-- comment 1 --> <div>some text</div> <div><p>Some more elements</p></div> <!-- end content --> <!-- comment 2 --> <div>some text</div> <div><p>Some more elements</p> <!-- end content --> </div> </html> I tried using the below XPath: //*[preceding-sibling::comment()[contains(., 'comment 1')]][following-sibling::comment()[contains(., 'end content')]] It works fine for first comment i.e. comment 1 but not working for second comment following