Having the redundant ns declarations bloats the file and slows parsing. I do
not know if it bloats/slows transmission of a similar hierarchy such as an
array of objects converted with XmlSerializer in the following web service:
[WebMethod]
MyStruct[] foo() {
MyStruct[] bar = new MyStruct[5];
for (int i = 0; i < 5 ++i) {
bar[i] = new MyStruct();
}
return bar;
}
Does each MyStruct in bar have its own namespace declaration in transit as
below, or does each MyStruct inherit the namespace declaration of
ArrayOfMyStruct?
<ArrayOfMyStruct xmlns="http://yadayada">
<MyStruct xmlns="http://yadayada">
...
</MyStruct>
<MyStruct xmlns="http://yadayada">
...
</MyStruct>
...
</ArrayOfMyStruct>
I am just trying to optimize my program for transmission/space/UI-latency
and XML handling is often a major offender. Having an Xml web-service that
transmits twice as much information as is necessary to yield the same effect
is silly, annoying, and detracts from a product that consumes it.
Greg
"John Saunders" wrote:
"Greg" <Gr**@discussions.microsoft.comwrote in message
news:08**********************************@microsof t.com...
If I have an XmlDocument with a deep hierarchy of nodes, with a
documentElement having an attribute xmlns="http://someurl.com" and all
children inheriting that namespace (but not having the xmlns attribute
explicitly declared), then why is it that when I perform
appendChild(someNode) on an existing node deep in the hierarchy, where
someNode has been created by an XmlSerializer with the namespace set to be
the aforementioned "http://someurl.com", the appended node has the xmlns
attribute explicitly declared in the output of saving the XmlDocument?
In other words, why doesn't AppendChild() remove redundant attributes that
are inherited from the parent, specifically xmlns?
May I ask, why do you care? The "xmlns" aren't really attributes. They're
namespace declarations. What kind of problem is this causing you?
John