Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 27th, 2006, 05:55 AM
Registered User
 
Join Date: Jan 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Creating an XML file from XSD

Hi peeps,

I hope somebody can help me as I'm a little stuck.

I'm creating a component that deals with credit card payments. The component must create two xml files to be used with the CC web service.

I have created XSD's for the two xml files and a collection of payment objects that contain all details needed to be inserted into the xml file.

For each payment object within the collection I want to create a an xml file based on the appropriate xsd, thus the file will be correctly formed and populated with the default values. Then I can populate the appropriate elements within the file with the values from the payment object.

The problem that I have is that I'm unsure how to use the schema to create the basic XML file.

Any assistance would be greatly appreciated.

Cheers
 
Old April 27th, 2006, 10:44 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

As far as I know you can't serialise to order simply based on an XML schema.
You can add certain attributes to the class's properties to specify element names etc. if they don't match the ones in the class or you can override the whole serialisation process but it's more a manual job.

http://msdn2.microsoft.com/en-us/library/83y7df3e.aspx

You can also take the other approach, create your class based on you schema using the XSD.exe tool in the .NET SDK. You get the basics of a class which can be fleshed out if necessary.

http://msdn.microsoft.com/library/de...ToolXsdexe.asp

--

Joe (Microsoft MVP - XML)
 
Old January 15th, 2007, 06:32 AM
Registered User
 
Join Date: Jan 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm currently having the same problem. Did you manage to create an xml file using the schema?
 
Old January 15th, 2007, 12:44 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

I have used xsd.exe for this as Joe has suggested above many times and it works well.
1. Look at the tutorial http://dotnetjunkies.com/QuickStartv.../XSDToCls.aspx
2. Make a class out of your xsd.
3. populate the class instance.
4. Serialise the class: http://dotnetjunkies.com/QuickStartv...bjFromXML.aspx

======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
 
Old January 16th, 2007, 08:41 AM
Registered User
 
Join Date: Jan 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi as far as i have understood ur problm.U have one XSD File
u want to convert it into xml file.
if this is the case
U can first convert the xmlschema in to dataset and then easily
u can convert dataset to xml....

yogs






Similar Threads
Thread Thread Starter Forum Replies Last Post
creating new xml file from existing deepee XML 1 July 25th, 2006 10:35 AM
XML To XML, using XSL & XSD supercop75 XSLT 1 April 8th, 2006 02:48 AM
Merging XSD files in one XSD file by using what? haoxuqian XML 1 November 4th, 2005 01:42 PM
Validating Xml files with XSD file ShaileshShinde VB.NET 2002/2003 Basics 1 September 12th, 2005 07:00 AM
Transform .xsd files to a .xml file lxu XSLT 0 July 19th, 2004 09:23 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.