The DOM/XmlWriter/whatever you are using should handle that for you. One minor point: you might find it easier to use XDocument (if you have 3.5) - the namespace usage is much simpler (IMO):
XNamespace ns = "http://consoso/foobar";
XDocument doc = new XDocument(
new XElement("Foo",
new XAttribute(XNamespace.Xmlns + "ns", ns), // alias
new XElement("Bar", "abc"),
new XElement(ns + "url", "http://foo/bar")
)
);
string s = doc.ToString();
Which creates:
<Foo xmlns:ns="http://consoso/foobar">
<Bar>abc</Bar>
<ns:url>http://foo/bar</ns:url>
</Foo>