I need help designing a class that I want to build. At the very basic level, I want to provide the user the capability to convert HTML to well-formed XML. I already have the code to do this; all I need to do know is put it together in a class. Here are some of the things I am considering putting in:
(pseudo VB.Net)
1. Property Document As String - gets or sets the document to convert to well formed XML
2. Method ToWellFormed As String - returns the well-formed version of Document
3. Method Load(uri As String) - sets Property Document with contents of file located at uri
- OR Method Load(filename As String) - sets Property Document with the contents of file located at filename
- OR Method Load(doc As String) - sets Property Document with the contents of doc (functionally the same as Property Document. If I do this, maybe I need to remove the Document Property.)
- OR Sub New(uri As String) OR Sub New(filename As String) OR Sub New(doc As String)
- OR never mind any of these since Property Document is already provided; let the user figure out how to set Document (but it might be nice to make the user's life easier by providing some sort of Load method)
4. Method ToPrettyPrint - returns results of ToWellFormed in pretty print
5. Method GetContents (includeAttributes as Boolean) - returns the concatenated values of nodes of ToWellFormed (similar to XmlNode.InnerXml except that a space is included between values); if includeAttributes = True, then Attribute Nodes are included in the concatenated values; otherwise, no
- OR maybe the argument should allow for a third option, e.g. "Smart." Smart will return the concatenated values of relevant attribute and element values (e.g. alt attribute is relevant, id attribute is not; title element is relevant, br is not, etc.). Relevant could be predetermined or configurable somehow (which means a configuration document must somehow be assigned to the class???)
6. Property IsWellFormed As Boolean - returns whether or not Document is well formed
Any suggestions how to organize this better? Please suggest better names if you can think of any. If you think I am putting in too much or too little features, please say so.
One more thing, I would like to offer this as a Web Service. Any suggestions or tips for that? Thanks.
Start Free Trial