8

Automated mode to convert XML files to SQL database?

 2 years ago
source link: https://www.codesd.com/item/automated-mode-to-convert-xml-files-to-sql-database.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Automated mode to convert XML files to SQL database?

advertisements

We have a bunch of XML files, following a schema which is essentially a serialised database form:

<table1>
   <column1>value</column1>
   <column2>value</column2>
</table1>
<table1>
   <column1>another value</column1>
   <column2>another value</column2>
</table1>
...

Is there a really easy way to turn that into an SQL database? Obviously I can manually construct the schema, identify all tables, fields etc, and then write a script to import it. I just wonder if there are any tools that could automate some or all of that process?


For Mysql please see the LOAD XML SyntaxDocs.

It should work without any additional XML transformation for the XML you've provided, just specify the format and define the table inside the database firsthand with matching column names:

LOAD XML LOCAL INFILE 'table1.xml'
    INTO TABLE table1
    ROWS IDENTIFIED BY '<table1>';

There is also a related question:

  • How to import XMl file into MySQL database table using XML_LOAD(); function

For Postgresql I do not know.

Related Articles

Convert xml file to xlsx file with VBA

How can I convert xml files to xlsx? The xml files existing in a folder and I want to save the xlsx files to an other folder. Example: Existing file: C:\Users\John\Documents\xml\data.xml Convert to this: C:\Users\John\Documents\xlsx\data.xlsxIs this

Import an XML file into SQL Server without BULK

I'm trying to import data from a XML file into a database. I've made a test script using BULK INSERT, but when I've tested on the live database, permissions for BULK are disabled. Attempt #1: BULK INSERT XMLTable FROM 'C:\Radu\test.xml' WITH (ROWTERM

Use the XML file as a database

How can I use a XML file as a database and execute some basic SELECT command only on it ! ex: select author from file.xml where title="MyTitle" <?xml version="1.0"?> <catalog> <book id="bk101"> <author>

read an xml file in the database

I want to store the contents of an xml file in the database. Is there an easy way to do it? Can i write some script that can do the task for me? The schema of the XML file looks like this: <schedule start="20100727120000 +0530" stop="201

Convert XML file to Flatten XML using C #

I need to convert a XML File to make it readable in Excel. The idea is to Flatten the XML file. In addition, I am using C# as most resources assist me with SQL which i do not need. Any help would do please. Source: <root> <product> <screen&

Insert an XML file into SQL Server

I'm trying to import an XML file into a SQL table. I found a few examples of code to do this, but I can't seem to get it to work. I've tried a few variations in my code but at this point I'm not sure if the issue is the XML file structure or my SQL.

Text file to converted XML file

I going to convert text file to XML. I use the following code. But it generate error in line 12. Can anyone correct the code. Error is in this line. writer.WriteString(lines[0].TrimEnd().Split(ca, 2)[1]); ------ "Index was outside the bounds of the a

How to convert xml file to php array?

This question already has an answer here: How to convert xml into array in php? 9 answers I've got strange xml file like this http://xxx.pl/tmp/tabela.xml, and I don't know how to convert it into an array. I tried something like this: <?php $get = fi

Convert XML files to JSON by ignoring attributes

I'm trying to convert an XML to JSON in JAVA removing the tag attributes from the XML. I tried using org.json.XML but it did not meet my needs. Is there a library for doing what I want to do? Example input: <?xml version="1.0"?> <compan

insert the xml file into sql

I want to insert Large xml values into sql using php. This is xml example : <?xml version="1.0" encoding="utf-8" ?> <contacts> <con> <id>1</id> <name>user_name</name> <city>city_name</

Can I modify the package.xml file in SQL bootstrapper to install a named SQL server instance

I want to use the SqlExpress2008 Bootstrapper for a new installation on Windows7, I do not want to use the default SQLEXPRESS Instance. I have attempted to edit the package.xml file located in: C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapp

How to create an XML file by SQL query?

I have a Select query which selects the top 10 values from table Create proc [dbo].[SP_Select_Top10] as select DISTINCT top (10) Score, FBid from FB_Player ORDER BY Score DESC What I need is to have the results of this query in xml file as. <player>

Convert XML file to variable class?

I am messing around on XStream to get used using it. I can convert my Person variable to XML to give me this <list> <Person> <name>Mitch</name> <age>17</age> <adress>Yehaaa</adress> <fav-hobbie>Program

Best practices for automating the creation of XML files for front-end access?

I am working on a custom PHP/MySQL CMS. The data managed in the CMS is exported to XML files via a PHP script that must be ran manually. A Flash/AS3-based front-end loads the XML files and displays the specified data. Is it advisable to setup some so

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK