XML is currently the most widely used data interchange format
So we're going to use the L scripting language to develop an XML access library
The following script file is a simple XML file access library that can generate simple XML files
#scplib
Definition: class, XML file
Start: class, XML file
Definition: String, XML file header
Definition: string, file body
Definition: string, start tag, "<"
Definition: string, line end tag, "/>"
Definition: string, end tag, ">"
Definition: string, paragraph end tag
Definition: Functions, inserting header, file header
Start: function, insert file header
#清空: String, XML file header
#连接: String, XML file header, file header
Empty: string, file body
Connection: string, file body, file header
Display: File body
End: function, inserting file header
Definitions: functions, adding nodes, node names
Start: Functions, adding nodes
Definition: string, node content
Connection: String, node content, start tag
Connection: String, node content, node name
Connection: String, node content, ""
Connection: String, node content, end tag
Connection: String, node content, start tag
Connection: String, node content, "/"
Connection: String, node content, node name
Connection: String, node content, end tag
Connection: string, file body, node content
Display: File body
End: function, add node
Definition: function, add child node, node name, name of child node
Start: function, add child nodes
Definition: String, node tail
Connection: string, end of node, start tag
Connection: string, tail of node, "/"
Connection: String, node trailer, node name
Connection: String, node tail, end tag
Definition: integer, trailing position, 0
Find: String, file Body, node tail, trailing position
Definition: string, node content
Connection: String, node content, start tag
Connection: String, node content, name of child node
Connection: String, node content, ""
Connection: String, node content, end tag
Connection: String, node content, start tag
Connection: String, node content, "/"
Connection: String, node content, name of child node
Connection: String, node content, end tag
If: Trailing position >=0, insert: string, file body, node content, trailing position
Display: File body
End: function, adding child nodes
Definitions: functions, adding node values, node names, node values
Start: function, add node value
Definition: String, node tail
Connection: string, end of node, start tag
Connection: string, tail of node, "/"
Connection: String, node trailer, node name
Connection: String, node tail, end tag
Definition: integer, trailing position, 0
Find: String, file Body, node tail, trailing position
If: Trailing position >=0, insert: string, file Body, node value, trailing position
Display: File body
End: function, add node value
Definitions: functions, adding attributes, node names, property names, property values
Start: function, add property
Definition: string, node start
Connection: String, node start, start tag
Connection: String, node start, node name
Definition: integer, starting position, 0
Definition: integer, length of node start, 0
Take size: String, node start, length of node start
Definition: String, attribute body, ""
Connection: String, attribute body, property name
Connection: String, attribute body, = "
Connection: String, attribute body, property value
Connection: String, attribute body, "\" "
Find: String, file Body, node start, start position
Calculation: Start position = start position + length of node start
If: Start position >=0, insert: string, file body, attribute body, start position
Display: File body
End: function, add property
Definition: function, save as file, file name
Start: function, Save as file
Delete: file, filename
Open: File, file1, file name
Write: File, file1, file body
End: function, Save as file
End: class, XML file
The following script is a reference to our own implementation of the XML library, instantiate an example of an XML class
#scp
Import: library, E:\SCRIPTENGINE\SCRIPTS\XMLLIB.SCP
Definition: string, generic XML file header, <?xml version= "1.0" encoding= "Utf-8" standalone= "yes"?>
#实例化一个XML文件对象
Definition: XML file, my XML file
Call: My XML file: function, insert file header, generic XML file header
Call: My XML file: function, add node, HTML
#调用: My XML file: function, add node value, HTML, I am an HTML file
Call: My XML file: function, add property, html,version,1.0
Call: My XML file: function, add child node, Html,book
Call: My XML file: function, add child node, Html,price
Call: My XML file: function, add attribute, Book,name, "C + +"
Call: My XML file: function, add property, price,value,100.00
Call: My XML file: function, save as file, C:\1.xml
Definition: String, str1
Wait: User input, str1
Developing an XML Access library using the L scripting language