Click here to Skip to main content
15,926,596 members
Home / Discussions / XML / XSL
   

XML / XSL

 
GeneralSerializing Arrays in .NET Pin
mohn331031-Dec-03 15:07
mohn331031-Dec-03 15:07 
Hi,

I'm serializing an array of objects using XML Serialization. Using attributes you can customize what the xml element names will be. If you serialize an array, the root name is prefixed with "ArrayOf". How do you change that? I tried using the [XmlArray( Elementname = "SomethingElse") ] attribute on the array, but it didn't seem to work.

I've seen examples where they use the "XmlRoot" attribute on the class name. But I'm serializing JUST the array, NOT a class. So I can't use that.

Basically here's what I have...

I have

MyType[] myArray;

and I want to serialize that...

XmlSerializer xs = new XmlSerialize( typeof( MyType[] ) );
xs.Serialize( fileStream, myArray );

I get...


<arrayofmytype>
<mytype>...
<mytype>...


Is there anyway to change <arrayofmytype> to something else?

Thanks.
GeneralRe: Serializing Arrays in .NET Pin
mohn331031-Dec-03 15:09
mohn331031-Dec-03 15:09 
GeneralRe: Serializing Arrays in .NET Pin
Heath Stewart2-Jan-04 11:44
protectorHeath Stewart2-Jan-04 11:44 
GeneralRe: Serializing Arrays in .NET Pin
mohn33102-Jan-04 14:16
mohn33102-Jan-04 14:16 
GeneralRe: Serializing Arrays in .NET Pin
Heath Stewart2-Jan-04 19:44
protectorHeath Stewart2-Jan-04 19:44 
Generalextract data from xml document Pin
samo7a30-Dec-03 11:06
samo7a30-Dec-03 11:06 
GeneralRe: extract data from xml document Pin
Nick Parker2-Jan-04 6:55
protectorNick Parker2-Jan-04 6:55 
GeneralProblem with transformation result Pin
tamekyle30-Dec-03 9:09
tamekyle30-Dec-03 9:09 
GeneralRe: Problem with transformation result Pin
Heath Stewart31-Dec-03 11:23
protectorHeath Stewart31-Dec-03 11:23 
GeneralRe: Problem with transformation result Pin
tamekyle2-Jan-04 4:15
tamekyle2-Jan-04 4:15 
Generalxmslt templates Pin
aynka200029-Dec-03 1:53
aynka200029-Dec-03 1:53 
QuestionHow to use array update the xml file?&#9608;&#9608;&#9608; Pin
nichen100128-Dec-03 13:42
nichen100128-Dec-03 13:42 
AnswerRe: How to use array update the xml file?&amp;#9608;&amp;#9608;&amp;#9608; Pin
Philip Fitzsimons6-Jan-04 3:02
Philip Fitzsimons6-Jan-04 3:02 
GeneralProblem adding web reference to Visual c++ application Pin
Anonymous27-Dec-03 9:52
Anonymous27-Dec-03 9:52 
GeneralRe: Problem adding web reference to Visual c++ application Pin
Anonymous27-Dec-03 9:57
Anonymous27-Dec-03 9:57 
Generalcrystal reports Pin
heba_zien27-Dec-03 9:34
heba_zien27-Dec-03 9:34 
GeneralProper Installation of MSXML Pin
Heath Stewart23-Dec-03 4:52
protectorHeath Stewart23-Dec-03 4:52 
GeneralXSD Pin
Large Data File22-Dec-03 7:30
Large Data File22-Dec-03 7:30 
GeneralRe: XSD Pin
Heath Stewart23-Dec-03 4:55
protectorHeath Stewart23-Dec-03 4:55 
GeneralRe: XSD Pin
Large Data File30-Dec-03 23:47
Large Data File30-Dec-03 23:47 
GeneralRe: XSD Pin
Heath Stewart31-Dec-03 3:51
protectorHeath Stewart31-Dec-03 3:51 
GeneralXML and Office Pin
Mauricio Ritter22-Dec-03 0:01
Mauricio Ritter22-Dec-03 0:01 
GeneralRe: XML and Office Pin
Philip Fitzsimons22-Dec-03 4:41
Philip Fitzsimons22-Dec-03 4:41 
QuestionWhat is the right XPath to.. Pin
Aryo Handono12-Dec-03 6:02
professionalAryo Handono12-Dec-03 6:02 
AnswerRe: What is the right XPath to.. Pin
Nick Parker12-Dec-03 6:55
protectorNick Parker12-Dec-03 6:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.