I have a question about HTML. I'd like to know if ALL tags have ALL the attributes that exist (height, margin, bgcolor, frontcolor).
I want to know this because I'd like to read HTML text using Purebasic. So I thought I'll need a tree structure to be able to handle all that. Now I thought I could make a structure for tags. This structure would contain things like width,height, x, y, margin etc. My approach so far:
Code: Select all
Global inputt.s = "<html><head><title>Titel</title></head><body><div><p>paragraph</p></div></body></html>"
Global i.i = -1
Global output.s = ""
Global *start.Character
Enumeration
#html
#body
#head
#footer
#p
#div
#link
#br
#script
#meta
#title
EndEnumeration
Structure tag
frontColor.i
backColor.i
type.i
EndStructure
Structure br
text.s
EndStructure
Structure p
text.s
List brs.br()
EndStructure
Structure link
text.s
href.s
EndStructure
Structure div
List ps.p()
List links.link()
EndStructure
Structure footer
List ps.p()
List links.link()
EndStructure
Structure body
List divs.div()
List footers.footer()
EndStructure
Structure meta
content.s
EndStructure
Structure title
text.s
EndStructure
Structure script
type.s
EndStructure
Structure head
List titles.title()
List metas.meta()
List scripts.script()
EndStructure
Structure html
List bodies.body()
List heads.head()
EndStructure
Procedure.i examineTag(output$,lookuponly.l = 0)
old_i.i = i
Select *start\c ;just a start
Case 'a' To 'z','A' To 'Z' ;etc
While *start\c >= '0' And *start\c <= '9'
output$ + Chr(*start\c)
*start + SizeOf(Character)
Wend
EndSelect
If lookuponly
i = old_i
EndIf
ProcedureReturn
EndProcedure
Procedure findTag(input$)
intag = #False
While i<Len(input$)
i=i+1
If Not intag And Mid(input$,i,1) = "<"
intag = #True
Continue
EndIf
If intag And Mid(input$,i,1) = ">"
intag = #False
Continue
EndIf
If Not intag
text.s = ""
text = text + Mid(input$,i,1)
output = output + text+#CRLF$
EndIf
If intag
text.s = ""
If Mid(input$,i,1) <> "<"
text = text + Mid(input$,i,1)
EndIf
output = output + text
EndIf
Wend
EndProcedure
findTag(inputt)
Debug output
Maybe someone has an answer to my question and/or could help doing the structure.
Looking forward to hearing from you all