R
rubyhacker
Question for you all. I want to treat HTML like XML
(which is no big deal).
But I want to find certain "special" tags (not real
HTML) and replace them with my own text.
It's macro-type stuff. Basically I want to output
the *same* HTML except for the text that replaced
the special tags.
I can't find any examples of generating XML with
REXML. It should be easy, I don't want it to be
too hard.
Contrived example below in case it helps.
How would you do this?
Thanks,
Hal
Input:
<html>
<body>
<p>Hi, there.</p>
<foo bar="this" bam="that">some more text</foo>
<p>That's all.</p>
</body>
</html>
Output:
<html>
<body>
<p>Hi, there.</p>
<p>I found a foo tag enclosing 'some more text' with
bar and bam values of 'this' and 'that'...</p>
<p>That's all.</p>
</body>
</html>
(which is no big deal).
But I want to find certain "special" tags (not real
HTML) and replace them with my own text.
It's macro-type stuff. Basically I want to output
the *same* HTML except for the text that replaced
the special tags.
I can't find any examples of generating XML with
REXML. It should be easy, I don't want it to be
too hard.
Contrived example below in case it helps.
How would you do this?
Thanks,
Hal
Input:
<html>
<body>
<p>Hi, there.</p>
<foo bar="this" bam="that">some more text</foo>
<p>That's all.</p>
</body>
</html>
Output:
<html>
<body>
<p>Hi, there.</p>
<p>I found a foo tag enclosing 'some more text' with
bar and bam values of 'this' and 'that'...</p>
<p>That's all.</p>
</body>
</html>