You should find the <p/> node and return all text() nodes, both inside and after. Depending on the capabilities of XPath Nokogiri, use one of these queries:
//p[1]/(descendant::text() | following::text())
If this does not work, use it instead, which should first find the first paragraph and may be slightly, but probably imperceptibly, slower:
(//p[1]/descendant::text() | //p[1]/following::text())
Probably an unsupported alternative to XPath 2.0 would be:
which means "all text nodes preceded by the first <p/> node in the document."
source share