HTML Parsing Indenter
Posted: Tue Aug 23, 2005 6:20 am
At the moment I'm working on an HTML generator writer. The idea is that there is a generator class, which will generate HTML tags. These tags (and the text) are stored in a list until the document is finished, and is then passed on to a writer class.
Here is the difficult bit, I want to be able to go through the tags and parse them for opening and closing. So if it detects < with no ! then it increments the indent, and if it finds a </ tag then it will decrement the indent (and tags finishing in /> have no effect)
Does anyone have any ideas for how I can process the strings, I have a fair idea on the comparison operation, it is just isolating parts of the string
Here is the difficult bit, I want to be able to go through the tags and parse them for opening and closing. So if it detects < with no ! then it increments the indent, and if it finds a </ tag then it will decrement the indent (and tags finishing in /> have no effect)
Does anyone have any ideas for how I can process the strings, I have a fair idea on the comparison operation, it is just isolating parts of the string