XML (eXtensible Markup Language) is a very widespread standard by which an exchange of data between different applications and over the WEB is possible. At first the data must be brought in XML form, however. This is relatively simple, once a text is parsed. For this TextTransformer is an ideal tool because parsers for all kinds of texts can be produced with it relatively easily. The functions which are then necessary to make a XML file from the parsed text can be downloaded as an import file for the interpreter page of the TextTransformer.
The use of the functions is demonstrated with the projects "Csv2XML.ttp" and "Csv2TreeXML.ttp", which are a simple parsers for comma separated values.
The functions are called directly during parsing in "Csv2XML.ttp". In "Csv2TreeXML.ttp" a parse tree is built first and the functions are then used to evaluate this tree.
By these projects you can parse for example the text:
There are following functions:
"WriteXMLtStart" writes the header of the xml document:
<?xml version="1.0" encoding="ISO-8859-1"?>
"WriteTagStart" writes a tag like: <Line>.
If the tag shall get some attributes, "WriteTagStart" is split into:
"WriteTagEnd" (="WriteXMLEnd") writes the end tag like: </Line>.
The content between two tags is written with "WriteXMLContent". This function uses the other function "Encode", which encodes some special characters.
With the vector m_vIndent and with the vector m_vTag stacks of tags and indents are managed.
An elegant possibility of getting a similar XML output without the functions above, is the use of a xerces DOM. This is demonstrated with the following project:
Last Update: 09 april 08
|to the top|