Un poco mas resumido para poder analizar el código y la informacion que se crea en el xml.
Código Delphi
[-]Var
tDocXmlNombre: string;
Xml: IXMLDOCUMENT;
nMaster, nPrimero, nSegundo, nTercero, nCuarto, nQuinto, nAtributo, nItem,
nItemSub, nCDATA: IXMLNODE;
begin
Xml := NewXMLDocument;
Xml.Version := '1.0';
Xml.Encoding := 'UTF-8';
Xml.Options := [doNodeAutoIndent];
nMaster := Xml.AddChild('Invoice');
nMaster.Attributes['xmlns'] :=
'urnasis:names:specification:ubl:schema:xsd:Invoice-2';
nMaster.Attributes['xmlns:cac'] :=
'urnasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2';
nMaster.Attributes['xmlns:cbc'] :=
'urnasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2';
nMaster.Attributes['xmlns:ccts'] := 'urn:un:unece:uncefact:documentation:2';
nMaster.Attributes['xmlns:ds'] := 'http://www.w3.org/2000/09/xmldsig#';
nMaster.Attributes['xmlns:ext'] :=
'urnasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2';
nMaster.Attributes['xmlns:qdt'] :=
'urnasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2';
nMaster.Attributes['xmlns:udt'] :=
'urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2';
nMaster.Attributes['xmlns:xsi'] :=
'http://www.w3.org/2001/XMLSchema-instance';
nPrimero := nMaster.AddChild('ext:UBLExtensions');
nSegundo := nPrimero.AddChild('ext:UBLExtension');
nSegundo.AddChild('ext:ExtensionContent').Text := '';
nPrimero := nMaster.AddChild('cbc:UBLVersionID');
nPrimero.Text := '2.1';
nPrimero := nMaster.AddChild('cbc:CustomizationID');
nPrimero.Text := '2.0';
nPrimero := nMaster.AddChild('cbc:ID');
nPrimero.Text := '12345678900-01-F001-0000001';
nPrimero := nMaster.AddChild('cbc:IssueDate');
nPrimero.Text := FormatDateTime('yyyy-mm-dd', Date);
nPrimero := nMaster.AddChild('cbc:IssueTime');
nPrimero.Text := FormatDateTime('hh-mm-ss',Time);
nPrimero := nMaster.AddChild('cbcueDate');
nPrimero.Text := FormatDateTime('yyyy-mm-dd',Date);
nPrimero := nMaster.AddChild('cac:Signature');
nPrimero.AddChild('cbc:ID').Text := 'tRucEmisor';
nSegundo := nPrimero.AddChild('cac:SignatoryParty');
nTercero := nSegundo.AddChild('cac:PartyIdentification');
nTercero.AddChild('cbc:ID').Text := 'tRucEmisor';
nCuarto := nSegundo.AddChild('cac:PartyName');
nCuarto.AddChild('cbc:Name').DOMNode.appendChild
(Xml.DOMDocument.createCDATASection('tRazonEmisor'));
nSegundo := nPrimero.AddChild('cacigitalSignatureAttachment');
nTercero := nSegundo.AddChild('cac:ExternalReference');
nTercero.AddChild('cbc:URI').Text := 'tRucEmisor';
nPrimero := nMaster.AddChild('cac:AccountingSupplierParty');
nItem := nPrimero.AddChild('cbc:CustomerAssignedAccountID');
nItem.Text := 'tRucEmisor'; nItem := nPrimero.AddChild('cbc:AdditionalAccountID');
nItem.Text := 'FE_CodigoTipoDoc(tRucEmisor)';
Xml.SaveToFile(ExtractFilePath(Application.ExeName) + '12345678900-01-F001-0000001.xml');