I am trying to use Regex in C # to match a section in an XML document and wrap this section inside a tag.
For example, I have this section:
<intro>
<p>this is the first section of content</p>
<p> this is another</p>
</intro>
and I want it to look like this:
<intro>
<bodyText>
<p> this is asdf</p>
<p> yada yada </p>
</bodyText>
</intro>
any thoughts?
I thought about this using the XPath class in C # or just reading the document and using Regex. I just can't figure it out anyway.
here is one try:
StreamReader reader = new StreamReader(filePath);
string content = reader.ReadToEnd();
reader.Close();
StreamWriter writer = new StreamWriter(filePath);
writer.Write(content);
writer.Close();
}
Thank!
source
share