I have the following HTML:
<html>
<body>
<h1>Foo</h1>
<p>The quick brown fox.</p>
<h1>Bar</h1>
<p>Jumps over the lazy dog.</p>
</body>
</html>
...and by using the RubyGem Nokogiri (a hpricot replacement), I'd like to change it into the following HTML:
<html>
<body>
<p class="title">Foo</p>
<p>The quick brown fox.</p>
<p class="title">Bar</p>
<p>Jumps over the lazy dog.</p>
</body>
</html>
In other words: How can I find and replace certain HTML tags by using Nokogiri? I know how to find them (using css keywords), but I don't know how to replace them while parsing the document.
Thanks for your help!