I wanted to generate the following using XmlSerializer :
<atom:link href="http://dallas.example.com/rss.xml" rel="self" type="application/rss+xml" />
So I tried to add a Namespace to my element :
[...]
[XmlElement("link", Namespace="atom")]
public AtomLink AtomLink { get; set; }
[...]
But the output is :
<link xmlns="atom" href="http://dallas.example.com/rss.xml" rel="self" type="application/rss+xml" />
So what is the correct way to generate prefixed tags ?
First off, the atom namespace is normally this:
In order to get your tags to use the
atomnamespace prefix, you need to mark your properties with it:You also need tell the
XmlSerializerto use it (thanks to @Marc Gravell):