c# - Replacing <p>, <div> tags within <td> tags? -


I am working on a special HTML stripper. In place of current stripper & lt; Td> Tag with tag and then & lt; P & gt; And & lt; Div & gt; Tag with double carriage-tags However, when stripping the code like this:

   First lesson & lt; / Td> & Lt; Td style = "background: # 330000" & gt; & Lt; P style = "color: # 660000; text-line: center" & gt; Some text & lt; / P & gt; & Lt; / Td>  

This creates (obviously)

  the first lesson some text  

us & lt; P & gt; Nothing in this case will change, so it produces:

  First text (tab) some text  

However, we want to keep a double cart Substitution replacement for other code where & lt; P & gt; Tag & lt; Td> The tags are not surrounded by.

Actually, we & lt; Td> \ T always tag and & lt; P & gt; And & lt; Div & gt; With tags \ r \ r only when they & lt; Td> Tag

Current code: (C #)

 In  of  // < TD & gt; Tag result = System.Text.RegularExpressions.Regex.Replace (Results, @ "& lt; td \ b (?: [^" "" "'] |" "" ["" "] *" "| |' [ ^ '] *') * & Gt; "," \ t ", system text, regular expression, regex option, ignore case); // and & lt; P & gt ;, & lt; DIV & gt; Place the // line line parameter (double line break) instead. And & lt; TR & gt; Tag result = System.Text.RegularExpressions.Regex.Replace (Results, @ "& lt; (div | tr | p) \ b (?: [^ & Gt;" "'] |" "[^"]] * "" | | '[^'] * ') * "," \ R \ r ", system text, regular expression, regex option. Ignore case);  

(the stripper has more code, this is the relevant part)

Any thoughts on how to do it without fully writing the whole dose?

EDIT: To not mention legal issues, I would not want to use a library so that it was included in the head due to the signing and project (which Has any other project included in the library). If there is no other solution, though, I would probably use the HTML Agility Pack.

Mostly, the stripper just looks for something that looks like a tag (Regx in regular expressions based on a large reggae, this is the replacement of the line breaks with R / R, and Dealing with multiple tabs is vulnerable to the custom stripping code.

Do you think about it Thought, which will have several parsing options in which to manipulate the tag?


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -