title: Is there any easer way to wipe all fixed sizes set for html nodes than I trying to code?
body: <p>I have an input strings like that:</p>
  
  <pre><code>&lt;span id = 'RTF_Text_101'  style="font-family:'Arial';font-size:12pt;text-align:left;"&gt;
  &lt;p lang="en-US" style="margin-top:0pt;margin-bottom:0pt;"&gt;&lt;span style="font-size:10pt;"&gt;aeqw&lt;/span&gt;&lt;/p&gt;
  &lt;p lang="en-US" style="margin-top:0pt;margin-bottom:0pt;"&gt;&lt;span style="font-size:10pt;"&gt;qwe&lt;/span&gt;&lt;/p&gt;
  &lt;p lang="en-US" style="margin-top:0pt;margin-bottom:0pt;"&gt;&lt;span style="font-size:10pt;"&gt;qwe&lt;/span&gt;&lt;/p&gt;
  &lt;table cellspacing="0" cellpadding="0pt" style="width:498.2pt;border-collapse:collapse;"&gt;
  &lt;colgroup&gt;
  &lt;col width="332" /&gt;
  &lt;col width="332" /&gt;
  &lt;/colgroup&gt;
  &lt;tr align="left" valign="top"&gt;
  &lt;td style="width:244pt; padding-right:1.8pt; padding-left:1.8pt; border-top: 1pt solid #000000; border-right: 1pt solid #000000; border-bottom: 1pt solid #000000; border-left: 1pt solid #000000;"&gt;
  &lt;p lang="en-US" style="margin-top:0pt;margin-bottom:0pt;"&gt;&lt;span style="font-size:10pt;"&gt;asd1&lt;/span&gt;&lt;/p&gt;
  &lt;/td&gt;
  &lt;td style="width:244pt; padding-right:1.8pt; padding-left:1.8pt; border-top: 1pt solid #000000; border-right: 1pt solid #000000; border-bottom: 1pt solid #000000; border-left: 1pt solid #000000;"&gt;
  &lt;p lang="en-US" style="margin-top:0pt;margin-bottom:0pt;"&gt;&lt;span style="font-size:10pt;"&gt;asd3&lt;/span&gt;&lt;/p&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr align="left" valign="top"&gt;
  &lt;td style="width:244pt; padding-right:1.8pt; padding-left:1.8pt; border-top: 1pt solid #000000; border-right: 1pt solid #000000; border-bottom: 1pt solid #000000; border-left: 1pt solid #000000;"&gt;
  &lt;p lang="en-US" style="margin-top:0pt;margin-bottom:0pt;"&gt;&lt;span style="font-size:10pt;"&gt;asd2&lt;/span&gt;&lt;/p&gt;
  &lt;/td&gt;
  &lt;td style="width:244pt; padding-right:1.8pt; padding-left:1.8pt; border-top: 1pt solid #000000; border-right: 1pt solid #000000; border-bottom: 1pt solid #000000; border-left: 1pt solid #000000;"&gt;
  &lt;p lang="en-US" style="margin-top:0pt;margin-bottom:0pt;"&gt;&lt;span style="font-size:10pt;"&gt;asd4&lt;/span&gt;&lt;/p&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/span&gt;
  </code></pre>
  
  <p>Those are generated by rtf to html conversion tool. The problem is that it makes tables with fixed sizes, while I need it to be dynamic.</p>
  
  <p>So, I need to replace all sizes (width, height) in this string that belongs to table related tags (table, tr, td).</p>
  
  <p>I started to code this:</p>
  
  <pre><code>//the input parameters for this funct is huge html piece and tag that should be "non sized"
  public void RemoveSizesFromStringForTag(ref string str, string tag)
  {
      int tag_start_index = -1; //current found tag start index
      int curr_search_pos = 0; //current position to start search for next tag
  
      while ((tag_start_index = str.IndexOf("&lt;" + tag, curr_search_pos)) &gt;= 0) //while we found some tag
      {
          int tag_end_index = str.IndexOf("&gt;", tag_start_index); //get it's end index
          string temp_part = str.Substring(tag_start_index, tag_end_index - tag_start_index); //substring tag liek that "&lt;table ... &gt;"
  
          bool replace_needed = false; //used as flag
  
          if (temp_part.ToLower().Contains("width")) //if substring contains width
          {
              //NOT IMPLEMENTED
              RemoveAttributeFromString(ref temp_part, "width"); // then remove this attribute from that string
              replace_needed = true; //and mark that we need to replace later
          }
  
          if (temp_part.ToLower().Contains("height"))
          {
              RemoveAttributeFromString(ref temp_part, "height");
              replace_needed = true;
          }
  
          if (replace_needed) // if replace needed
          {
              str.Remove(tag_start_index, tag_end_index - tag_start_index); //we remove string with sizes
              str.Insert(tag_start_index, temp_part); //and insert string without sizes
          }
  
          curr_search_pos = tag_start_index + temp_part.Length; //correcting current search position
      }
  }
  
  public void RemoveAttributeFromString(ref string str, string attr)
  {
      int attr_start_index = -1;
      int curr_search_pos = 0;
  
      while ((attr_start_index = str.IndexOf(attr, curr_search_pos)) &gt;= 0)
      {
          //honestly I stopped here to understand what to do next,
          //since stoo much of cases possible that I cannot handle.
  
          //it could be: id = 'asd'width='10%'height=5px, it could be with spaces, with ", set via style width:10%
      }
  }
  </code></pre>
  
  <p>And at certain point I found that my approach is very hard, because that sizes could be set by many ways <code>(width=10px, width = 10px, width = '10px', id='asd'width="10px"style='...')</code>. There is too many cases and it very hard to find the attribute borders to remove.</p>
  
  <p>So, is there any easer aproach?</p>