Read an XML (without DTD/schema) and write the values into db



Objective : I'm writing a program in C# to read an XML (without DTD/schema) and write the values of each tag into a database(SQL Server).


Approach : I'm using an xml parser (XMLReader) to parse the XML. I'm creating the tables(currently manually but planning to automate it) based on XSD created using xsd.exe. Based on the tag-name i'm fetching all the attributes and corresponding values and storing it into corresponding tables.


Problem : Now if any new tag is introduced into the xml being parsed i have to change my code written for parsing and storing.


Is there any other approach i should use or can i use same approach with modifications to achieve the objective.


No comments:

Post a Comment