 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Ian Hinson Guest
|
Posted: Sat Apr 22, 2006 8:03 pm Post subject: Unwanted xmlsn="" attribute inserted by MSXML |
|
|
Hi,
I'm using the DOMDocument wrapper component (created by importing msxml.dll
as MSXML_TLB) to produce an XML document programmatically.
But the output I get looks like this:
--------
<?xml version="1.0" encoding="ISO-8859-1"?>
<Root xmlns="http://mynamespace.com">
<Child xmlns="">value</Child>
</Root>
--------
The problem is the unwanted (xmlns="") attribute on the child node.
The code that produced this is listed below.
(Variable "dom" is a TDOMDocument component that wraps MS's
IXMLDOMDocument.)
var
instr: IXMLDOMProcessingInstruction;
root, node: IXMLDOMElement;
attr: IXMLDOMAttribute;
node: IXMLDOMElement;
begin
instr := dom.createProcessingInstruction('xml', 'version="1.0"
encoding="ISO-8859-1"');
dom.DefaultInterface.appendChild(instr);
root := dom.createElement('Root');
attr := dom.createAttribute('xmlns');
attr.value := 'http://mynamespace.com';
root.setAttributeNode(attr);
dom.DefaultInterface.appendChild(root);
root.appendChild(dom.createTextNode(#13#10#9));
node := dom.createElement('Child');
node.text := 'value';
root.appendChild(node);
root.appendChild(dom.createTextNode(#13#10));
dom.save('xml.txt');
end;
The problem does not occur if I remove the namespace attribute from the root
node.
Is this a problem with MS's implementation of IXMLDOMDocument in msxml.dll
or am I doing something wrong?
Thanks,
Ian |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|