Unwanted xmlns = "" in _di_IXMLNode
I am creating an xml file to display in Excel using _di_IXMLDocument. But for some tags I get an unnecessary extra (empty) xmlns attribute that makes the file unreadable for Excel ... This is what I do:
...
_di_IXMLNode worksheet = workbook->AddChild("Worksheet");
worksheet->SetAttribute("ss:Name",Now().DateString());
...
and this is what happens:
<Worksheet xmlns="" ss:Name="2008-12-11">
Where does xmlns come from? How can I get rid of it?
EDIT: Additional information: If I try to add the xmlns attribute to the Worksheet myself, like this:
...
_di_IXMLNode worksheet = workbook->AddChild("Worksheet");
worksheet->SetAttribute("xlmns","Foo");
worksheet->SetAttribute("ss:Name",Now().DateString());
...
The "Worksheet" child nodes then receive only the xmlns attributes instead!
<Worksheet xmlns="Foo" ss:Name="2008-12-11">
<Table xmlns="">
0
source to share
2 answers
Ok I looked at this question. The trick was to create child nodes and tell which namespace they belong to and then not dump it ...
_di_IXMLNode worksheet = workbook->AddChild("Worksheet","workbooks-namespace",false);
worksheet->SetAttribute("ss:Name",Now().DateString());
this gives the desired output:
<Worksheet ss:Name="2008-12-11">
0
source to share