I am working on designing html parser for study purpose. Where I am first creating a overall design.
Data structure to store html element.
Base
: HtmlBaseElement
Derived
: HTMLElement, PElement, HtagElemement, ImgElement, BodyElement, StrongElement
Basically I will create derived class for each type of element in html.
I need to write this html file back to a file and allow user to add element in already parsed html file.
This is what I am thinking :
First Approach:
-
Create a
BaseVisitor
which is having visit function for each type of element. -
Create a Derived Visitor Class
WriteHtmlVisitor
to write whole file which willvisit
each element in HTML datastructure.
Second Approach:
I can also use a class WriteHtmlFile
, having object of HTMLElement
and then write this using getter of all elements.
Which is best way to write html file and adding new elements in file.
I am just looking for suggestion, as this is in design phase.
Thanks.
Aucun commentaire:
Enregistrer un commentaire