Insert client data

Top  Previous  Next

Examples > XML > Insert client data

 

A real application for the evaluation of the XML tree is the transportation of data from customer demands in an insert instruction of the database language SQL. The texts Client1.txt -- Client5.txt are examples for these demands. These texts aren't complete XML documents. After an introducing text, the customer data follow in an in an incomplete XML form.

 

 

The start rule Clients jumps by SKIP directly to the beginning of the XML part:

 

SKIP

"XML-Format:"

element[nDoc]

 

The already known element production is called then. The construction of a SQL instruction is finally carried out in the function: PrintSQLInsert. By

 

out << "INSERT INTO `tt_address` (`uid`, ...

 

the table and the fields, which shall be filled with values, are specified. The values are then selected from the tree in the order in which they are used. A function table isn't necessary for this simple tree. E.g.:

 

pos = xNode.findNextValue("EMAIL"); // email

out << pos.firstChild().value() << "\", \"";

 

So an insert instruction is got, by which the values can be inserted into a database. E.g.:

 

INSERT INTO `tt_address` (`uid`, `pid`, `tstamp`, `hidden`, `name`, `title`, `email`, `phone`, `mobile`, `www`, `address`, `company`, `city`, `zip`, `country`, `image`, `fax`, `deleted`, `description`, `module_sys_dmail_category`, `module_sys_dmail_html`) VALUES( "103", "43", "1087224349", "0", "  Santa Clause", "", "sc@gift.org", "333 333", "", "", "", "", "North Pole", "", "Greenland", "", "", "", "", "", "1" );

 

By a N:1-transformation in the transformation manager the insert instructions of all five example files can be written into a single text file, so that all data sets then can be inserted into the database at once.

 

 



This page belongs to the TextTransformer Documentation

Home  Content  German