var i; xmld; node,nodec, tuotenode; tekstinode,tekstitnode; T,ttxt; dbname; procedure lisaaArvo(xml,node,nimi, data); var ObjNewNode, ObjNewText; begin objNewNode := xml.createElement(nimi); objNewText := xml.createTextNode(data); objNewNode.appendChild(objNewText); node.appendchild(objNewNode); end; begin dbname := 'kirkar'; t := ttbtable.Create(nil); t.databasename := dbname; t.tablename := 'tuote'; t.open; ttxt := ttbtable.Create(nil); ttxt.databasename := dbname; ttxt.tablename := 'tuotetxt'; ttxt.open; xmld := CreateOleObject('microsoft.xmldom'); xmld.validateonparse := false; node := xmld.createProcessingInstruction('xml',' version=''1.0'' encoding=''UTF-8'''); xmld.appendchild(node); node := xmld.createelement('skjdata'); nodec :=xmld.createelement('tuotteet'); xmld.appendchild(node); node.appendchild(nodec); i:=0; while not t.eof do begin tuotenode := xmld.createelement('tuote'); nodec.appendchild(tuotenode); lisaaArvo(xmld,tuotenode,'numero',t.FieldByName('numero').asstring); lisaaArvo(xmld,tuotenode,'nimi',t.FieldByName('nimi').asstring); lisaaArvo(xmld,tuotenode,'hinta',t.FieldByName('hinta').asfloat); ttxt.setrange1(t.FieldByName('numero').asstring,t.FieldByName('numero').asstring); ttxt.first; if not ttxt.eof then begin tekstitnode := xmld.createelement('tekstit'); tuotenode.appendchild(tekstitnode); while not ttxt.eof do begin tekstinode := xmld.createElement('teksti'); tekstitnode.appendchild(tekstinode); lisaaarvo(xmld,tekstinode,'otsikko',ttxt.FieldByName('otsikko').asstring); lisaaarvo(xmld,tekstinode,'onhtml',ttxt.FieldByName('onhtml').asboolean); lisaaarvo(xmld,tekstinode,'teksti',ttxt.FieldByName('teksti').asstring); ttxt.nexT; end; end; ttxt.cancelrange; inc(i); t.nexT; end; xmld.save('koe.xml'); t.close; xmld := unassigned; showmessage('koe.xml tallennettu '+inttostr(i)+' tuotetta'); end;