0

I'm a bit stuck with the XML namespaces. I would like to ask for a little help with it.

What I need...My namespace looks like:

<?xml version="1.0" encoding="iso-8859-2"?>
<Application_data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">

What I did is:

procedure BeginExport;
var
  FOutputXML: IXMLDOMDocument;
  vNode: IXMLDOMNode;
begin
  DoBeginBeginExport;

  if FOutputXML = nil then
  begin
    FOutputXML := CoDOMDocument.Create;
    FOutputXML.appendChild(FOutputXML.createProcessingInstruction('xml', 'version="1.0" encoding="iso-8859-2"'));      

    vNode := FOutputXML.appendChild(FOutputXML.createElement('Application_data')); 
    vNode.attributes.setNamedItem(vNode.ownerDocument.createAttribute('????')).text := '"http://www.w3.org/2001/XMLSchema-instance';

  end else FOutputXML.removeChild(FOutputXML.firstChild);
  DoAfterBeginExport;
end;

With "xmlns:xsi" after Createattribute does not work. Anyone can help me what did I wrong or what is the easiest way to set namespace attribute?

Steve88
  • 2,366
  • 3
  • 24
  • 43

1 Answers1

0

I solved with this but I think it is not the best solution.

//vAttr: IXMLDOMAttribute;

vAttr := FOutputXML.createAttribute('xmlns:xsi');
vAttr.value := 'http://www.w3.org/2001/XMLSchema-instance';
vNode.attributes.setNamedItem(vAttr);
vAttr := FOutputXML.createAttribute('xmlns:xsd');
vAttr.value := 'http://www.w3.org/2001/XMLSchema-instance';
vNode.attributes.setNamedItem(vAttr);
Steve88
  • 2,366
  • 3
  • 24
  • 43