* Keith Hill wrote in microsoft.public.dotnet.xml:
>I am creating an XmlDocument in code and then using XmlTextWriter via
>doc.WriteTo(xwriter) to output the result to a text box. I have a root
[quoted text clipped - 10 lines]
> <Foo xmlns="" />
></Root>
If you call CreateElement without any namespace it creates an element
without any namespace. In XML, this is expressed via xmlns="". If you
want to have the Foo element in the same namespace as the Root element
you need to specify the namespace for CreateElement. Remember that
<Root xmlns="http://tempuri.org">
<Foo xmlns="http://tempuri.org" />
</Root>
is equivalent to
<Root xmlns="http://tempuri.org">
<Foo />
</Root>
For more information on XML namespaces try the various MSDN articles
and e.g.
* http://www.rpbourret.com/xml/NamespacesFAQ.htm
* http://www.jclark.com/xml/xmlns.htm

Signature
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Keith Hill - 07 Jan 2005 21:10 GMT
That works and thanks for the pointer to FAQ. That's good reading.
--
Keith
> If you call CreateElement without any namespace it creates an element
> without any namespace. In XML, this is expressed via xmlns="". If you
[quoted text clipped - 16 lines]
> * http://www.rpbourret.com/xml/NamespacesFAQ.htm
> * http://www.jclark.com/xml/xmlns.htm
okie_greg - 23 May 2005 22:18 GMT
So that it is clear, in order to use a default namespace under the .Net
FX DOM, you have to specify the default? That is odd for a couple
reasons. First, a default can be defined as a value to use in the
absence of a provided value. This behavior of the DOM implementation
is changing that definition to if a particular value is supplied, we
will represent it as the default, yuck!. Second, in parent-child
entity relationships, it is the normal pattern for the child to take on
the attributes of it's parent unless specified as different (just like a
default, only oriented in objects hierarchies). Again, this behavior
changes that relationship, again, yuck!
--
okie_greg