Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/MacControls/HTMLViewer Mac/DOM functions
Function:
Required plugins for this example: MBS MacBase Plugin, MBS MacCocoa Plugin, MBS MacControls Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacControls/HTMLViewer Mac/DOM functions
This example is the version from Sun, 17th Mar 2012.
Project "DOM functions.rbp"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control HTMLViewer1 Inherits HTMLViewer
ControlInstance HTMLViewer1 Inherits HTMLViewer
EventHandler Sub Open() me.LoadURL "http://www.monkeybreadsoftware.de/" End EventHandler
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() dim Document as DOMDocumentMBS = HTMLViewer1.mainFrameMBS.DOMDocument dim htmlDocument as DOMHTMLDocumentMBS = DOMHTMLDocumentMBS(Document) MsgBox htmlDocument.Title End EventHandler
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action() dim d as DOMDocumentMBS = HTMLViewer1.mainFrameMBS.DOMDocument MsgBox str(CountNodes(d)) End EventHandler
End Control
Control PushButton3 Inherits PushButton
ControlInstance PushButton3 Inherits PushButton
EventHandler Sub Action() dim d as DOMDocumentMBS = HTMLViewer1.mainFrameMBS.DOMDocument dim links(-1) as string FindLinks d,links MsgBox Join(links,EndOfLine) End EventHandler
End Control
Function CountNodes(d as DOMNodeMBS) As integer dim count as integer = 1 dim a as DOMNodeListMBS = d.childNodes dim i,c as integer c=a.length-1 for i=0 to c dim n as DOMNodeMBS = a.item(i) if n<>Nil then count = count + CountNodes(n) end if next Return count End Function
Sub FindLinks(d as DOMNodeMBS, links() as string) dim count as integer = 1 dim a as DOMNodeListMBS = d.childNodes dim i,c as integer c=a.length-1 for i=0 to c dim n as DOMNodeMBS = a.item(i) if n isa DOMHTMLAnchorElementMBS then dim anchor as DOMHTMLAnchorElementMBS = DOMHTMLAnchorElementMBS(n) links.Append anchor.href end if FindLinks n, links next End Sub
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacControls Plugin.




Links
MBS Xojo Chart Plugins