schemaLocation problem with Serialization.

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I am using serialization in c# 3.0 (trying to serialize).  I want to use the schemaLocation xml attribute as that is what is in an example i need to stick to. I cannot work out what c# attribute i need to use to do this.

I have tried:

<div class=codeseg>
<div class=codecontent>
<div class=codesniptitle><span style="width:100% Code Snippet
public Class exampleClass
{
        [System.Xml.Serialization.XmlAttributeAttribute("schemaLocation", Namespace = "http://www.rewerse.net/I1/2006/R2ML http://oxygen.informatik.tu-cottbus.de/R2ML/0.4/R2ML.xsd")]
        public string schemaLocation;
}

where "exampleClass" is the root node in the serialized document.

The output should be like:

<div class=codeseg>
<div class=codecontent>
<div class=codesniptitle><span style="width:100% Code Snippet
<exampleClass schemaLocation="http://oxygen.informatik.tu-cottbus.de/R2ML/0.4/R2ML.xsd
     ...
</exampleClass>
what comes out is more like:

<div class=codeseg>
<div class=codecontent>
<div class=codesniptitle><span style="width:100% Code Snippet
<exampleClass xmlns="http://oxygen.informatik.tu-cottbus.de/R2ML/0.4/R2ML.xsd
     ...
</exampleClass>





View the full article
 
Back
Top