Last post Nov 22, 2019 06:22 AM by samwu
Nov 21, 2019 07:40 PM|steppinthrax|LINK
This is quite simple...
I make a ADO.NET connection to a database and query a table into a dataset.
I can use the Dataset.WriteXML and DataSet.WriteXMLSchema to generate an XML form of the table or generate the schema.
I want to generate the XML based on a give Schema. I tried editing the existing schema provided by dataset.writexmlschema and then use the dataset.readxmlschema then use the dataset.writexml to generate the new XML based on the schema I just read. However
It dosen't work in this manner.
How can I do this with using no 3rd party utilities if possible!!!
Nov 21, 2019 08:22 PM|mgebhard|LINK
Visual Studio has all the tools you need.
Keep in mind that XSD is an XML stylesheet. While it is possible to generate an XML file the XML node values and attributes are unknown without an XML file.
Nov 21, 2019 11:52 PM|steppinthrax|LINK
What I have is data coming from the database. I need to generate an XML file, however I don't want to hard-code the formation of that XML file within the c#. I understand you can use various XML serialization classes within .NET to do this. What's the
best way to do this....
Nov 22, 2019 06:22 AM|samwu|LINK
I need to generate an XML file, however I don't want to hard-code the formation of that XML file within the c#.
You can try to use xsd tool to create a class base on your .xsd file,then create instance of class, defined in XSD schema and XmlSerialize it.
More information about generating XML file using XSD file you can refer to this link:https://stackoverflow.com/a/6530496
The xsd tool is not 3rd party tool. https://docs.microsoft.com/en-us/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe