Sam, I don't really have anything new to add but can comment on the good
suggestions already raised.

* the XmlSerializer allows a great deal of customizability (using
attributes) but only based on schema, so that might not help you. As
suggested before one approach might be to get the xml instances as close
to your target format as you can using the XmlSerializer then apply a
simple XSLT to finish the job. 
* you wrote that it'd be too much work to come up with a schema for your
format and you don't even know if it's schema-describable anyway. One
easy way to investigate this further is to try a schema inference tool.
I believe if you run xsd.exe on an xml file it will attempt to create a
schema for it as best it can. Who knows, maybe your xml format *is*
schema-describable! If it is then you can feed the schema into xsd.exe
/c to get XmlSerializer-ready classes.
* the IXmlSerializable interface is doc'd as "for internal use only" or
something like that. This is because it's not fully functional for web
services and is used only to support Dataset. If you don't care about
schema (and if you've reached this option you've concluded that you
don't) you should be able to use the ReadXml and WriteXml methods
without trouble to do custom serialization in whatever format you want. 

hope this helps
alex


-----Original Message-----
From: Sam Gentile [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, April 24, 2002 9:50 AM
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.


>From: Jeremy Hopkin <[EMAIL PROTECTED]>
>Reply-To: dotnet discussion <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Re: [DOTNET] Some Basic XML "Serialization" Questions
>Date: Wed, 24 Apr 2002 07:10:38 -0700
>
>Have you tried implemententing
System.Xml.Serialization.IXmlSerializable
>
>You can then serialise and deserialise in whatever way you want.
>Return null or nothing from GetSchema(), and you're away.
>
>You now have the two functions ReadXml and WriteXml to play with
>which recieve System.Xml.XmlReader and System.Xml.XmlWriter
>respectively.
>
>The you can read and write in pretty much anyway you want,
>is that the kind of thing you are after?
>
>
>Jeremy
>
> >>I understand fairly well the use of the [Serializable] attribute
> >>and the native Binary
> >>IFormatter interface. I understand also that there is XML and SOAP
> >>serialization. But all of these seem to serialize to the CLR's view
of
> >>an object or something with XML Schema types. What I actually have
to do
> >>is: we have some XML files that we create in our application. They
were
> >>defined before XML schema and they are not Schema compliant. I have
some
> >>.NET classes I am defining and I need to put the data/state in them
> >>written out to these XML files in a certain format. The trick is I
can't
> >>just dump .NET's "view" of the objects. The XML files have a certain
> >>format. Can I make use of any of XML Serialization or do I just have
> >>"pound" XML into the files using classes in System.Xml? In other
words,
> >>how customizable is the XML serialization? Any ideas would be
greatly
> >>appreciated.
>
>You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or
>subscribe to other DevelopMentor lists at http://discuss.develop.com.




---------------------
Sam Gentile
.NET Consultant
Co-author: Wrox Visual C++ .NET: A primer for C++ developers
BLOG: http://radio.weblogs.com/0105852/
http://www.project-inspiration.com/sgentile/DotNet.htm
http://www.project-inspiration.com/sgentile/
---------------------------




_________________________________________________________________
Join the world's largest e-mail service with MSN Hotmail.
http://www.hotmail.com

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

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