Thanks, Mike. I think I'm close, but I'm having a bit of trouble. I've actually extracted the body I'm trying to work with out of a nasty XML document, and after I've obtained it, I want to parse it. I don't have a complete doc, it's just a bunch of <p> tags in a string. (see the 'body' variable in my snippet below)
I took a shot at parsing it, but I'm having two problems:
1) the <inlineTag> nodes aren't being removed
2) I can't figure out how to get my string back when done without it trying to put HTML or XML declaration tags around it.
For #1, I tried parsing it with Nokogiri::XML, Nokogiri::HTML, and Nokogiri:Slop. I have a feeling that I don't want to replace the nodes with a Nokogiri::XML::Text object?
For #2, I've tried returning doc with doc.to_s, doc.to_html, and doc.to_xml. All seem to wrap it in something.
Thank you very much!
----------------------------------
require 'rubygems'
require 'nokogiri'
# This actually came from something extracted from a document so it's not a complete doc
body = <<-eos
<p><inlineTag name="subhead">January 1:</inlineTag> <inlineTag name="body">Event 1.</inlineTag>
<strong>Title 1. </strong> This is the first paragraph­with entites­ that we have.
We also have <a href="#">links</a></p>
<p><inlineTag name="subhead">January 2:</inlineTag> <inlineTag name="body">Event 2.</inlineTag>
<strong>Title 2. </strong>This is the second paragraph­with entites­ that we have.
We also have <a href="#">more links</a></p>
eos
# What I'm trying to get:
#
# <p>January 1: Event 1. <strong>Title 1.</strong> This is the first paragraph­with entites­
# that we have.We also have <a href="#">links</a></p>
#
# <p>January 2: Event 2. <strong>Title 2.</strong> This is the second paragraph­with entites­
# that we have.We also have <a href="#">more links</a></p>
doc = Nokogiri::XML(body)
doc.search(".//inlineTag").each do |node|