我正在使用XhtmlTextWriter创建一些XHTML代码。
我想创建一个带边框的表。
private string NewTable()
{
string str = "ROWS";
StringWriter stringWriter = new StringWriter();
using (XhtmlTextWriter writer = new XhtmlTextWriter(stringWriter))
{
writer.AddAttribute(HtmlTextWriterAttribute.Width, "500");
writer.AddAttribute(HtmlTextWriterAttribute.Border, "2");
writer.RenderBeginTag(HtmlTextWriterTag.Table);
writer.Write(str);
writer.RenderEndTag();
}
return stringWriter.ToString();
}
输出:
<table width="500">
ROWS
</table>
缺少border属性。