Search code examples
xmlautomationmsxml

MSXML and namespaces with prefix


I have to use MSXML6 to create a xml-file and need namespaces with prefixes - for example such:

<root xmlns="aaa.com" xmlns:b="bbb.com" xmlns:c="ccc.com">
    <child>...</child>
    <a:child>...</a.child>
    <b:child>...</b.child>
</root>

I found no example how to create a such structure. It's important that the namespaces are defined in the root-element and not in the childreen (e.g. NOT < child xmlns="bbb.com" >)

Has anybody a hint for me?


Solution

  • Explicitly create the namespace-tag mappings on the root element yourself. Additional child nodes will inherit those mappings.