Importing flat XML data into SQLite database in c#.net -


i have generated xml file exporting sqlite database in c#.net.my generated xml like-

<root>    <name1>       <names>          <id>5</id>                     <from>germany</from>          <to>france</to>          <through>             <via>                  <id>7</id>                  <routeno>5<routeno>                  <route>vienna<route>              </via>          </through>                 </names>      <names>          <id>10</id>                     <from>us</from>          <to>canada</to>          <through>             <via>                  <id>8</id>                  <routeno>10<routeno>                  <route>mexico<route>              </via>          </through>                 </names>    </name1> </root> 

then transformed file flat xml data -

<names id="5" from="germany" to="france">      <through id="9" routeno="5" route="vienna" />      <through id="10" routeno="5" route="russia" />  </names>  

i have imported xml file sqlite dataabse. used following codes import-

sqliteconnection sqlite_conn = new sqliteconnection("data source=sglight_empty.fmeda;version=3;new=true;compress=true;");             ndbunit.core.indbunittest sqlitedatabase = new ndbunit.core.sqllite.sqlliteunittest(sqlite_conn);             string xsdfilename = "myxsd.xsd";             string xmlfilename = "myxml.xml";              sqlitedatabase.readxmlschema(xsdfilename);             sqlitedatabase.readxml(xmlfilename);  sqlitedatabase.performdboperation(ndbunit.core.dboperationflag.cleaninsertidentity); 

now, problem works normal xml file can't import flat xml file transformed normal xml. me how modify can import data flat xml ?

an issue consider whether or not sqlite, correct xsd flattened xml, able recognized , match xml database schema generated full xml. why need flatten xml in first place?

that being said, there xsd tool comes windows sdk can infer xsd arbitrary xml file. copied "flat" xml file named temp.xml, ran xsd temp.xml, , received xsd definition:

<?xml version="1.0" encoding="utf-8"?> <xs:schema id="newdataset" xmlns="" xmlns:xs="http://www.w3.org/2001/xmlschema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">   <xs:element name="names">     <xs:complextype>       <xs:sequence>         <xs:element name="through" minoccurs="0" maxoccurs="unbounded">           <xs:complextype>             <xs:attribute name="id" type="xs:string" />             <xs:attribute name="routeno" type="xs:string" />             <xs:attribute name="route" type="xs:string" />           </xs:complextype>         </xs:element>       </xs:sequence>       <xs:attribute name="id" type="xs:string" />       <xs:attribute name="from" type="xs:string" />       <xs:attribute name="to" type="xs:string" />     </xs:complextype>   </xs:element>   <xs:element name="newdataset" msdata:isdataset="true" msdata:usecurrentlocale="true">     <xs:complextype>       <xs:choice minoccurs="0" maxoccurs="unbounded">         <xs:element ref="names" />       </xs:choice>     </xs:complextype>   </xs:element> </xs:schema> 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -