xml| Backup | data
$fields =mysql_list_fields ("Embed", $table, $con);
$j = 0;
$num _fields=mysql_field_name ($fields, $j);
echo $num _fields;
while ($j <mysql_num_fields ($fields)) {
$num _fields=mysql_field_name ($fields, $j);
$filestr. = "<" $num _fields. " > ";
$filestr. = $row [$j];
$filestr. = "</". $num _fields. " > ";
$j + +;}
$filestr. = "</". $table. " > ";
}
$filestr. = "</". $table. " S> ";
Echo $filestr;
Here is the file manipulation code
$filename = $table. ". XML ";
$FP =fopen ("$filename", "w");
Fwrite ($fp, $FILESTR);
Fclose ($FP);
Echo "Datasheet". $table. " Backup has been successful! ";? >
</body>
By using the above files, you can perform a backup of the tables selected in the database.
The above mainly introduces two ways of using XML Backup database operation method, in fact, is not complex, through XML, we can back up a variety of databases, of course, can also be related to the method of the backup of the XML document back to the database, here is not described in detail.
2. Exchanging data between different databases
Another feature of XML is that it can be used to exchange data in different databases, as described above, we can export some type of database file from one system to another, and then import the data into other databases in another system. XML makes the exchange of data between different databases across platforms more convenient.
What if we want to send data from Oracle to SQL Server? If we don't use XML, everything will be very complex, and using XML to encapsulate the data in Oqacle into an XML file can be read by another database system, such as SQL Server.
3. Display data
Because XML itself focuses on content, it does not work for display data itself, and XML data is displayed in a very different way, through CSS (cascading Style Sheet), XSL (extensible Stylesheet Language) or data Binding, and many other ways to display it.
Since XML is separate from data and style, we can arbitrarily change the display format of the data in our own imagination without doing anything with the XML document, which makes the data more flexible and free.
Because the XML display is more complex to describe, this is not covered in detail.
4, itself as data storage
In fact, we have just introduced the use of XML to back up the database, forget to introduce, XML itself can be used to store data, in fact, in the following cases, using XML to store data is very good.
Information data is more complex:
In fact, a complex data does not necessarily be very good through the database to display, but it can be very good to use XML to display. For example, the record of a book, usually has the name and the author, if the author only one, can be very convenient to use the database to display, but if a book has two, three or more authors, this time, XML can easily solve
Separate fields are complex and large
Also for the record of the book mentioned just now, if we want to put each chapter of the book in the database is not a good store, the database of each field is long, will waste a lot of space.
Data types and search speed are not important
Of course, there are some problems with XML, although the search for XML has been greatly optimized, but the speed is still very slow. And all of the data in XML is stored through strings, so it's not very appropriate to use XML to store data for data type requirements that are very important.
Database is small, but can be extended
In addition, because of the good scalability of XML, XML is also useful for small, data storage that needs to be constantly modified.
In addition, if your system has multiple servers and database systems, you can use XML, and XML can easily transfer data from Linux to the Windows platform. In addition, consider the choice of XML as a database for long-term storage.
When to store data without XML
By using the previous data storage comparison with XML, we should also know when it is not appropriate to use XML for data storage, if we have a high demand for database queries, XML is not appropriate, and if the data type of the stored data is important, XML is not appropriate.
Any technology has drawbacks, XML is not appropriate, but it will provoke all the data processing and transmission of the responsibility, which is the birth of XML is an important reason. In the future, we will see the existence of XML in more products and applications, especially when it comes to data transfer.
Zhou
Lenovo Group embedded Application Research and Development Department software engineer, the main research interest is the application of XML in the technology Next generation Web service. You can contact him through zhoush@legend.com.