Namespaces
By default, namespaces are inherited from the parent. Or you can define new aliases for your children to use with the xmlns:alias= syntax or you can override the default namespace that will be used for the element (and, of course, its children) using the xmlns= syntax.
First example:
<opensearch:totalResults>1000</opensearch:totalResults>
It is required that the namespace alias "opensearch" be defined by the parent element - possibly in a different namespace. For example:
<myRoot xmlms:opensearch="http://a9.com/-/spec/opensearch/1.1/"> <opensearch:totalResults>1000</opensearch:totalResults> </myRoot>
Although this means that the "myRoot" element is in a different namespace, namely, by default (with an empty namespace or with its own parent).
Insert
To really add an element with the correct namespace, you will need to use the namespace and not its alias ("opensearch").
Therefore, to add a new element, you need to either grab the namespace from the parent node (or just know it and hard code).
eg.
feed.ElementExtensions.Add("totalResults", "http://a9.com/-/spec/opensearch/1.1/", 1000);
But note that you are limited or will not control the specific alias specified for your namespace. To do this, you will need to control the XML serialization process a bit ...
Reddog
source share