Generating XML from CSV and XSD
i need convert csv file xml based on xsd. easier approach this?
example of csv:
type,name,mfgdate,selldate,owner
car,toyota,01/12/2012,,sa
car,honda,1/1/2010,1/2/2012,sa
truck,toyota,1/1/1965,,,
truck, ford,,,,ca
xsd looks this:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="vehicles"
targetnamespace="http://tempuri.org/vehicles.xsd"
elementformdefault="qualified"
xmlns="http://tempuri.org/vehicles.xsd"
xmlns:mstns="http://tempuri.org/vehicles.xsd"
xmlns:xs="http://www.w3.org/2001/xmlschema"
>
<xs:element name="vehicles">
<xs:complextype>
<xs:sequence>
<xs:element name="cars" maxoccurs="1" minoccurs="0">
<xs:complextype>
<xs:sequence>
<xs:element maxoccurs="unbounded" name="car" minoccurs="1">
<xs:complextype>
<xs:attribute name="type" type="xs:string" use="required" />
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="mfgdate" type="xs:date" use="required" />
<xs:attribute name="selldate" type="xs:date" />
<xs:attribute name="owner" type="xs:string" />
</xs:complextype>
</xs:element>
</xs:sequence>
</xs:complextype>
</xs:element>
<xs:element name="trucks" maxoccurs="1" minoccurs="0">
<xs:complextype>
<xs:sequence>
<xs:element maxoccurs="unbounded" name="truck" minoccurs="1">
<xs:complextype>
<xs:attribute name="type" type="xs:string" use="required" />
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="mfgdate" type="xs:date" use="required" />
<xs:attribute name="owner" type="xs:string" />
</xs:complextype>
</xs:element>
</xs:sequence>
</xs:complextype>
</xs:element>
</xs:sequence>
</xs:complextype>
</xs:element>
</xs:schema>
sometimes schema user give might change. need write generic solution takes csv , xsd files input , generate xml file. please me this
thanks in advance.
check csv xml
http://dotnetdud.blogspot.com/2008/10/c-csv-to-xml-conversion-csv-to-xml.html
if post answers question, please click "mark answer" on post , "mark helpful"
Visual Studio Languages , .NET Framework > Visual C#
Comments
Post a Comment