BDO TOOLS  -  To XML Split Files BDO Tools

Use the To XML tool to create an XML file from a text file.

The field list of each line of the input file must be enclosed by parentheses.



Example 1
 (1, "France", "Paris")
 (2, "Germany", "Berlin")
 (3, "Hungary", "Budapest")

As each of the lines above contains 3 fields, and as each field list can be considered to be well-structured, the following XML output is easily created:

 <geography>
  <country>
    <id>1</id>
    <name>France</name>
    <capital>Paris</capital>
  </country>
  <country>
    <id>2</id>
    <name>Germany</name>
    <capital>Berlin</capital>
  </country>
  <country>
    <id>3</id>
    <name>Hungary</name>
    <capital>Budapest</capital>
  </country>
 </geography>

Example 2
 insert into customers values ();
 ()
 (Atlantic, Pacific, Indian)
 To be or not to be (that is the question)
 (Lion, Panther, Tiger)

The lines above cannot be considered to be well-structured:
  • The first and second lines each contain zero fields.
  • The third and fifth lines each contain 3 fields.
  • The fourth line contains 1 field.

The To XML tool will process the example shown above as follows. The line that contains the largest number of fields is identified. This is the third line in the example above. Each parent tag may then be assigned this number of child tags. So, if you elect to generate XML tags for all 3 child fields, and you specify the following:
  • root tag
    • geography
  • parent tag
    • country
  • child tags
    • id
    • name
    • capital

each input line will be treated as having 3 fields, and the To XML tool will create the following XML structure.

 <geography>
  <country>
    <id></id>
    <name></name>
    <capital></capital>
  </country>
  <country>
    <id></id>
    <name></name>
    <capital></capital>
  </country>
  <country>
    <id>Atlantic</id>
    <name>Pacific</name>
    <capital>Indian</capital>
  </country>
  <country>
    <id>that is the question</id>
    <name></name>
    <capital></capital>
  </country>
  <country>
    <id>Lion</id>
    <name>Panther</name>
    <capital>Tiger</capital>
  </country>
 </geography>

Obviously, if you put rubbish in, you'll get rubbish out.

Note
To split an input file into a number of XML files, use the Split Files tool.
 
Copyright © 2019 Brian D. Ogilvie www.bdozone.com  :