I'm parsing a sgml file. Each entry is something like this:
<key n=1>xzsd:test
<sk id=1 hi=1>test
<tag1>.............</tag1>
<tag2>.............</tag2>
................
</sk>
<sk id=2>test2
<tag1>.............</tag1>
<tag2>.............</tag2>
................
</sk>
</key>
I want to replace <key n=1>...</key>
with some HTML markup. I'm currently replacing tag by tag, but it would probably be more efficient to just retrieve everything inside the <key>
tag.
How could I make this code compile:
entry = Regex.Replace(entry, "<key .*?>.*</key>", "<div class='key'>$2<div>");//Only interested in the second match.
Regex skReg = new Regex(@"<sk...>", RegexOptions.Compiled);
foreach (Match ItemMatch in ItemRegex.Matches(entry))
{
//Do parsing of contents of each sk tag
}
The sgml does not have any newlines