Sam,

Have you looked at the XML serialisation attributes?  These give you a very
great deal of control over the shaping of the XML, so you can save to and
load from a predefined XML format.  I've used them successfully to
interoperate with non-.NET XML formats.

For example, suppose your file format is:

<?xml version="1.0"?>
<my-class>
  <some-name>123</some-name>
</my-class>

Then you can declare your code class as:

[XmlRoot("my-class")]
public class MyClass
{
  [XmlElement("some-name")]
  public int MyProperty { get; set; }
}

You use XmlSerializer to actually do the serialization.  It takes care of
translating between the code elements and the XML nodes using the mapping
specified in the attributes.  The save/load code is about four lines.
(Note: you do get some Schema-related namespace declarations when you save,
but you can make sure they don't get used anywhere, and you can still read
in files that don't have the NS declarations.)

Does this sound like it might meet your requirement?

Cheers,

--
Ivan Towlson
Thales Contact Solutions



-----Original Message-----
From: Sam Gentile [mailto:[EMAIL PROTECTED]]
Sent: 24 April 2002 17:50
To: [EMAIL PROTECTED]
Subject: Re: [DOTNET] Some Basic XML "Serialization" Questions


Yes, I think so as long as they don't have to do anything with a schema.
This predates schema and there just is way too much work to make a schema. I
just want to take the stuff in the C# classes and "spit it out" into the XML
files in the format that they require. They have certain elements and order,
etc. I know I am being vague but I don't want to post the files.



**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

**********************************************************************

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to