FoodCandy!

HtmlWriter Class Reference

Extends XmlTextWriter to provide Html writing feature which is not as strict as Xml writing. For example, Xml Writer encodes content passed to WriteString which encodes special markups like &nbsp to &bsp. So, WriteString is bypassed by calling WriteRaw. More...

List of all members.


Public Member Functions

 HtmlWriter (TextWriter writer)
 HtmlWriter (StringBuilder builder)
 HtmlWriter (Stream stream, Encoding enc)
override void WriteProcessingInstruction (string name, string text)
override void WriteString (string text)
 The reason why we are overriding this method is, we do not want the output to be encoded for texts inside attribute and inside node elements. For example, all the   gets converted to &nbsp in output. But this does not apply to HTML. In HTML, we need to have   as it is.
override void WriteComment (string text)
override void WriteStartElement (string prefix, string localName, string ns)
 This method is overriden to filter out tags which are not allowed.
override void WriteAttributes (XmlReader reader, bool defattr)
 This method is overriden to filter out attributes which are not allowed.

Public Attributes

bool FilterOutput = true
 If set to true, it will filter the output by using tag and attribute filtering, space reduce etc.
bool ReduceConsecutiveSpace = false
 If true, it will reduce consecutive   with one instance.
string[] AllowedTags
 Set the tag names in lower case which are allowed to go to output.
bool RemoveNewlines = false
 New lines
are replaced with space which saves space and makes the output compact.
string[] AllowedAttributes
 Specify which attributes are allowed. Any other attribute will be discarded.
Uri BaseHref = null
 Base href to adjust images and links.
Uri RewriteImgSrc = null

Detailed Description

Extends XmlTextWriter to provide Html writing feature which is not as strict as Xml writing. For example, Xml Writer encodes content passed to WriteString which encodes special markups like &nbsp to &bsp. So, WriteString is bypassed by calling WriteRaw.


Member Function Documentation

override void WriteString string  text  ) 
 

The reason why we are overriding this method is, we do not want the output to be encoded for texts inside attribute and inside node elements. For example, all the   gets converted to &nbsp in output. But this does not apply to HTML. In HTML, we need to have   as it is.

Parameters:
text 

When you are reading RSS feed and writing Html, this line helps remove those CDATA tags


Member Data Documentation

string [] AllowedAttributes
 

Initial value:

 new string[] { "href", "target", "border", "src", "valign", "align", "width", 
            "height", "color", "size", "class", "style", "type", "name", "value", "rel" }
Specify which attributes are allowed. Any other attribute will be discarded.

string [] AllowedTags
 

Initial value:

 new string[] { "p", "b", "i", "u", "em", "big", "small", "strike",
                                "div", "img", "span", "blockquote", "code", "pre", "br", "hr", "table", "tr", "td", "th", "h1", "h2", "h3",
                                "ul", "ol", "li", "del", "ins", "strong", "a", "font", "dd", "dt", "object", "param", "embed", "link" }
Set the tag names in lower case which are allowed to go to output.


The documentation for this class was generated from the following file:
  • HtmlReaderWriter.cs
© FoodCandy, 2006-2007, All Rights Reserved | FoodCandy | Sun Oct 7 10:48:52 2007 | Doxygen 1.4.6-NO