If i have some empty tags like this
<td width="15px"/>
Agility pack fixes them to be like
<td width="15px"></td>
Is anything possible to do to override this behavior ?
If i have some empty tags like this
<td width="15px"/>
Agility pack fixes them to be like
<td width="15px"></td>
Is anything possible to do to override this behavior ?
Try this before saving:
if (HtmlNode.ElementsFlags.ContainsKey("td"))
{
HtmlNode.ElementsFlags["td"] = HtmlElementFlag.Empty | HtmlElementFlag.Closed;
}
else
{
HtmlNode.ElementsFlags.Add("td", HtmlElementFlag.Empty | HtmlElementFlag.Closed);
}
This changes the behavior for all td
elements which may not be what you want. I don't know of a way to accomplish this per-node.
While @Corbin March's answer doesn't work as desired, it's the only one I've found that comes close. The problem is that HAP still does some additional fixup that makes this a problem.
From the original code:
<td width="15px"/>
By set the ElementFlags as above the closing element tag indeed is not created, however the original trailing "/" is removed. This could be a problem depending on your scenario, it was for me. The original fragment becomes:
<td width="15px">