views:

104

answers:

0

Hi , I am new to XML and want to create an XML file using IXmlDocument having namespace prefix only on root tag using delphi 2006.


I tried following code for append namespace prefix on created file

xmlDoc := TXmlDocument.Create(nil); try xsiNS := rsxsiNS; lNS1 := 'urn:dnspXML:' + 'r2'; lNS3 := lNS1 + ' dnspXML/dnspXML_r2.xsd';

  xmlDoc.Active := True;
 // xmlDoc.ParseOptions := [poPreserveWhiteSpace];
  xmlDoc.Options := [doNodeAutoIndent];
 // xmlDoc.Options := [doAutoPrefix];
  xmlDoc.Version := '1.0';
  xmlDoc.Encoding := 'utf-8';
  if aAUSAMISchemaReq then
  begin
    tableNode := xmlDoc.AddChild('dnspXML');
    tableNode.Attributes['xmlns:n1'] := lNS1;
    tableNode.Attributes['xmlns:xsi'] := xsiNS;
    tableNode.Attributes['xsi:schemaLocation'] := lNS3;
    headerNode := tableNode.AddChild('Header');
    ------ continue remaining code----

above code create XMLfile having name space prefixes at all element and I want to create XML file only name space prefix at root node .


please suggest how can i do it using delphi 2006 programming.

Thanks