Ok, so im working a project that im not going to release much about so far. Im trying to parse an html type language i am making myself. Im using an XML Reader to parse it into nodes and attributes and etc. Im a little confused on how im going to get this to work. I need to parse the html
andseperate them into controls into a list of the derived class "Control".
Heres the class :
Imports System.Xml
Imports System.IO
Namespace Markup
Public Class Markup
Private ControlList As List(Of Control)
Sub New()
End Sub
Public Sub Parse(ByVal HtmlString As String)
Dim CurrentControl As Control = Nothing
Dim LastElement As String = Nothing
Dim LastEndElement As String = Nothing
Using Parser As XmlReader = XmlReader.Create(New StringReader(HtmlString))
While Parser.Read()
Select Case Parser.NodeType
Case XmlNodeType.Element
LastElement = Parser.Name
Try
Catch ex As Exception
End Try
Case XmlNodeType.Attribute
Case XmlNodeType.Text
Case XmlNodeType.EndElement
LastEndElement = Parser.Name
End Select
End While
End Using
End Sub
End Class
End Namespace
I need to seperate it in to the objects but i have no clue how to keep track of everything. In the Try Catch in the beginning is where it is going to select the control. Im going to add a Handler class to select which object it is depending on the name. Here is the "Control" class so far,
whichinclude the default attributes.
Public Class Control
Public ID As String
Public Width As Integer = 0
Public Height As Integer = 0
Public Margin As _Margin
Public Padding As _Padding
Structure _Margin
Dim Top As Integer
Dim Left As Integer
Dim Right As Integer
Dim Bottom As Integer
End Structure
Structure _Padding
Dim Top As Integer
Dim Left As Integer
Dim Right As Integer
Dim Bottom As Integer
End Structure
End Class
The Inheriting classes will look something like this.
Namespace Markup.Controls
Public Class Div
Inherits Control
End Class
End Namespace
Does anyone have a clue how i can do this?
Notes
- I need to fully parse it myself as it will have custom controls and custom rendering.
- I cant use anyone else's class because of that-/\
- I will be rendering the controls based on the list of controls.
---
Andrewbob - I would be on the fucking copter of rofls
Programmer, Web Developer, and Graphics Designer