Platforms to show: All Mac Windows Linux Cross-Platform
/Util/XML Validator/XML Validator
Required plugins for this example: MBS Util Plugin
Last modified Fri, 16th May 2019.
You find this example project in your MBS Xojo Plugin download as a Xojo project file within the examples folder: /Util/XML Validator/XML Validator
Download this example: XML Validator.zip
Project "XML Validator.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control xmlSchema Inherits TextArea
ControlInstance xmlSchema Inherits TextArea
End Control
Control xmlInput Inherits TextArea
ControlInstance xmlInput Inherits TextArea
End Control
Control Results Inherits TextArea
ControlInstance Results Inherits TextArea
End Control
Control RunButton Inherits PushButton
ControlInstance RunButton Inherits PushButton
EventHandler Sub Action()
// with events?
'Dim v As New MyXMLValidatorMBS(xmlSchema.Text)
// or without
Dim v As New XMLValidatorMBS(xmlSchema.Text)
Dim xml As String = xmlInput.Text
xml = ReplaceLineEndings(xml, EndOfLine.UNIX) // make line numbers work
Dim r As Integer = v.ValidateString(xml)
results.Text = ""
Dim messages() As XMLValidatorMessageMBS = v.Messages
For Each message As XMLValidatorMessageMBS In messages
results.AppendText "Message: "+message.Message
results.AppendText EndOfLine
results.AppendText "Line: "+Str(message.Line)
results.AppendText EndOfLine
results.AppendText "Code: "+Str(message.Code)
results.AppendText EndOfLine
results.AppendText "File: "+message.FileName
results.AppendText EndOfLine
results.AppendText EndOfLine
Next
If r = 0 Then
MsgBox "Valid!"
Else
MsgBox "Failed with error "+Str(r)
End If
Exception x As XmlException
MsgBox x.message
End EventHandler
End Control
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
Control Label2 Inherits Label
ControlInstance Label2 Inherits Label
End Control
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class MyXMLValidatorMBS Inherits XMLValidatorMBS
EventHandler Sub Error(message as XMLValidatorMessageMBS)
Break
End EventHandler
EventHandler Sub Warning(message as XMLValidatorMessageMBS)
Break
End EventHandler
End Class
End Project
See also:
Download this example: XML Validator.zip
The items on this page are in the following plugins: MBS Util Plugin.