Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# XML ASP.NET4.0
i have a xml file
named
 
data.xml
data in this file like...
 
<countryData>
   <Country>
      <CName>AMERICAN SAMOA</CName>
      <CCode>AS</CCode>
   </Country>
   <Country>
      <CName>ANDORRA</CName>
      <CCode>AD</CCode>
   </Country>
   <Country>
      <CName>ANGOLA</CName>
      <CCode>AO</CCode>
   </Country>
   <Country>
</countryData>
 
now i want to insert that data in table
 
Table Defination like..
 
Id int
CName varchar(20)
CCode nchar(2)
 
then how can i import xml data to Table.....
 
plese help...
 
thnx
Posted 28-Jan-12 3:29am
PKriyshnA1.7K
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

You can use ADO.NET DataSet ReadXml method. Here is MSDN example. DataSet.ReadXml[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

That depends on how you want to import it; via code or SSIS.
 
For SSIS you may want to look at this http://blogs.msdn.com/b/mattm/archive/2007/12/11/using-xml-source.aspx[^]
 
For code there is nothing special. Parse the xml and insert.
 
If you give a little more detail maybe we can give you a more specific answer
  Permalink  
v2
Comments
PKriyshnA at 28-Jan-12 9:21am
   
simply i have a data in xml file but i want to use that data in project as a sql server database
 
so i want to import xml data in sql server 2008 database table
 
DATA IN XML IS:


AMERICAN SAMOA
AS


ANDORRA
AD


ANGOLA
AO



 
and DATA IN TABLE SHOULD BE:
 
ID CName CCode
1 AMERICAN SAMOA AS
2 ANDORRA AD
3 ANGOLA AO
Mark Nischalke at 28-Jan-12 10:03am
   
Restating your question doesn't help to clarify anything.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.150302.1 | Last Updated 29 Jan 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100