Home > Back-end >  Delphi7 XMLDocument root node attributes
Delphi7 XMLDocument root node attributes

Time:09-16

Var
Xml: TXMLDocument;
Rootnode, node: IXMLNode;
The begin
Xml:=TXMLDocument. Create (nil);
//Xml LoadFromFile (' triple-a. Xml ');
Try
//add version information '& lt; ? The XML version="1.0" encoding="GB2312"?> '
Xml. Active:=True;
Xml. Version:='1.0';
Xml Encoding:='GB2312';

Rootnode:=Xml. CreateNode (' CIF_INFO ');
Rootnode. Attributes [' a '] :='1.0';
Rootnode. Attributes [' XMLNS] :='http:\\aaa.com';

Xml. DocumentElement:=Rootnode;
Node:=Xml. CreateNode (' TXNCODE ');
Rootnode..childnodes. Add (node);
Node. The Text:='420001';

Xml. SaveToFile (' triple-a. Xml);
XML. Active:=False;
Showmessage (' create success! ');
The finally
Xml. Free;
end;
end;

Generate XML file

<? The XML version="1.0" encoding="GB2312"?>
- & lt; CIF_INFO a="1.0" XMLNS="http:\\aaa.com" & gt;


In TXNCODE XMLNS="" how to remove the XMLNS=" "

The right should be
<? The XML version="1.0" encoding="GB2312"?>
- & lt; CIF_INFO a="1.0" XMLNS="http:\\aaa.com" & gt;
420001 & lt;/TXNCODE>

Ask ace to give directions! Thank you very much!
  • Related