Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


XML Namespace Prefix

From: "Techno_Dex" <nospamchurst@--------.--->
To: NULL
Date: 11/1/2006 11:51:00 AM

Can anyone tell me how to add an XMLNamespace prefix to a C# class 
declaration?  I have a couple of different namespaces that must be declared 
in my XML file but I can't figure out what class/property attributes I need 
to add to have a namespace prefix generated in front of the element when the 
class is serialized.

I am looking for "rex" so the serialization will occur like the following.
<rex:ElementName>
  <rex:Value1> A</rex:Value1>
  <rex:Value2> B</rex:Value2>
</rex:ElementName>

So far all I am able to come up with is
<ElementName xmlns="rex">
  <Value1 xmlns="rex"> A</Value1>
  <Value2 xmlns="rex"> B</Value2>
</rex:ElementName >

I get this when I have the following
[XmlElementAttribute(ElementName="Foo", IsNullable=true, 
Form=XmlSchemaForm.Qualified)]
public class Foo
{
    [XmlElement("ElementName")]
    public ElementName ElementName
    {
        get {return menElementName;}
        set {menElementName = value;}
    }
}

public class ElementName
{
    [XmlElement("Value1")]
    public string Value1
    {
        get;
        set;
     }
    [XmlElement("Value2")]
    public string Value2
    {
        get;
        set;
     }
} 




transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent