Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/Tools/Tidy/Tidy XML
Function:
Required plugins for this example: MBS Tools Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Tools/Tidy/Tidy XML
This example is the version from Sat, 17th Feb 2017.
Project "Tidy XML.rbp"
FileTypes
Filetype text
End FileTypes
Class WindowSimple Inherits Window
Control EditField1 Inherits TextArea
ControlInstance EditField1 Inherits TextArea
End Control
Control EditField2 Inherits TextArea
ControlInstance EditField2 Inherits TextArea
End Control
EventHandler Sub Open() dim t as TidyDocumentMBS // the easiest way by just passing strings in and out t=new TidyDocumentMBS t.InstallErrorBuffer const input="<test><firstName>Bob</firstName><lastName>Miller</test>" t.OptionXmlTags = true t.OptionXhtmlOut = false t.OptionUpperCaseAttrs = false t.OptionUpperCaseTags = false t.OptionQuiet = true t.OptionQuoteAmpersand = true t.OptionQuoteMarks = true call t.ParseString(input) call t.CleanAndRepair call t.RunDiagnostics t.OptionForceOutput=true EditField1.text=t.SaveString EditField2.text=t.ErrorBuffer End EventHandler
End Class
MenuBar MenuBar1
MenuItem UntitledMenu2 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
Class MyOutput Inherits TidyOutputMBS
EventHandler Sub WriteByte(value as integer) s=s+chrb(value) // I know it is UTF8, so show a copy e.text=DefineEncoding(s,Encodings.UTF8) End EventHandler
Property e As TextArea
Property s As string
End Class
Class MyInput Inherits TidyInputMBS
EventHandler Function EndOfFile() As boolean Return index=count End EventHandler
EventHandler Function GetByte() As integer // return one byte index=index+1 Return ascb(midb(data,index,1)) End EventHandler
EventHandler Sub UngetByte(value as integer) index=index-1 // we hope the value is the one from the string End EventHandler
Sub Constructor(s as string) data=s count=lenb(s) index=0 End Sub
Property Private count As integer
Property Private data As string
Property Private index As integer
End Class
Class MyTidyDocument Inherits TidyDocumentMBS
EventHandler Function Filter(level as integer, line as integer, column as integer, message as string) As boolean MsgBox message End EventHandler
End Class
End Project

See also:

Feedback, Comments & Corrections

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




Links
MBS Xojo Plugins