procedure TForm2.btnSaveLayersClick(Sender: TObject);
function createElement(
const xmldoc: DomDocument; parentNode: IXMLDOMNode; szNodeName, szNodeValue:
string): boolean;
var
node : IXMLDOMNode;
begin
Result := false;
if (xmldoc =
nil)
or (szNodeName = '
')
then
exit;
node := xmldoc.createElement(szNodeName);
Result := node <>
nil;
if (node <>
nil)
then
begin
if (szNodeValue <> '
')
then
node.text := szNodeValue;
if (parentNode <>
nil)
then
parentNode.appendChild(node)
else
xmldoc.documentElement.appendChild(node);
end;
end;
var
XMLFile :
string;
XMLDoc : DomDocument;
XMLLayers : IXMLDOMNode;
XMLNode : IXMLDOMNode;
i : Integer;
begin
XMLDoc := CoDOMDocument.Create;
XMLDoc.loadXML('
<?xml version="1.0" encoding="ISO-8859-1"?><root/>');
XMLLayers := XMLDoc.createElement('
layers');
XMLDoc.documentElement.appendChild(XMLLayers);
with ImageEnVect1
do
begin
for i := 1
to LayersCount - 1
do
begin
XMLNode := XMLDoc.createElement('
layer');
XMLDoc.documentElement.appendChild(XMLNode);
createElement(XmlDoc, XMLNode, '
posx', IntToStr(Layers[i].PosX));
XMLDoc.documentElement.appendChild(XMLNode);
end;
end;
XMLFile := ExtractFilePath(ParamStr(0)) + '
Text.xml';
XMLDoc.save(XMLFile);
end;