How to create an XML file using TXML Document in Delphi 7 -
How to create an XML file using TXML Document in Delphi 7 -
i have used next code create xml document :
procedure tform1.btncreatexmlclick(sender: tobject); var rootname:string; childname:string; attrchild:string; ixml: idomdocument; iroot, inode, inode2, ichild, iattribute: idomnode; begin xmldoc.active:=false; xmldoc.xml.text:=''; xmldoc.active:=true; xmldoc.filename:='c:\documents , settings\a\desktop\new text document.xml'; ixml := xmldoc.domdocument; //iroot:=ixml.documentelement(ixml.createelement('xml')); iroot := ixml.appendchild(ixml.createelement ('xml')); // node "test" inode := iroot.appendchild (ixml.createelement ('test')); inode.appendchild (ixml.createelement ('test2')); ichild := inode.appendchild (ixml.createelement ('test3')); ichild.appendchild (ixml.createtextnode('simple value')); inode.insertbefore (ixml.createelement ('test4'), ichild); // node replication inode2 := inode.clonenode (true); iroot.appendchild (inode2); // add together attribute iattribute := ixml.createattribute ('color'); iattribute.nodevalue := 'red'; inode2.attributes.setnameditem (iattribute); // show xml in memo memxmloutput.lines.text:=formatxmldata(xmldoc.xml.text); end;
i output in memxmloutput xml document not show output when seen in notepad ot ie. problem? in advance
remove this:
xmldoc.filename:='c:\documents , settings\a\desktop\new text document.xml';
and add together after code done creating xml document:
xmldoc.savetofile('c:\documents , settings\a\desktop\new text document.xml');
delphi
Comments
Post a Comment