An example of XML saving file, MSXML, Adodb.Stream.

zhaozj2021-02-16  50

// save file to XML

Var Sourcefile = "c: //manage.vsd";

Var TargetxmlFile = "D: //tmp/test.xml";

VAR ado_stream = new activXObject ("adodb.stream");

VAR XML_DOM = New ActiveXObject ("Microsoft.xmLDom");

XML_DOM.LOADXML (' ');

XML_Dom.documentelement.setttribute ("XMLns: DT", "URN: Schemas-Microsoft-COM: DataTypes");

Var l_node1 = XML_Dom.createElement ("file1");

l_node1.datatype = "bin.base64";

ADO_STREAM.TYPE = 1; // 1 = adtypebinary

ADO_STREAM.Open ();

ADO_STREAM.LOADFROMFILE (SOURCEFILE);

L_node1.nodetypedValue = ado_stream.read (-1); // -1 = adreadall

ADO_STREAM.CLOSE ();

XML_Dom.documentelement.Appendchild (l_node1);

XML_Dom.Save (TargetXmlfile);

// restore file from xml

Var Sourcefile = "c: //manage.vsd";

Var TargetxmlFile = "D: //tmp/test.xml";

VAR ado_stream = new activXObject ("adodb.stream");

VAR XML_DOM = New ActiveXObject ("Microsoft.xmLDom");

XML_DOM.LOADXML (' ');

XML_Dom.documentelement.setttribute ("XMLns: DT", "URN: Schemas-Microsoft-COM: DataTypes");

Var l_node1 = XML_Dom.createElement ("file1");

l_node1.datatype = "bin.base64";

ADO_STREAM.TYPE = 1; // 1 = adtypebinary

ADO_STREAM.Open ();

ADO_STREAM.LOADFROMFILE (SOURCEFILE);

L_node1.nodetypedValue = ado_stream.read (-1); // -1 = adreadall

ADO_STREAM.CLOSE ();

XML_Dom.documentelement.Appendchild (l_node1);

XML_Dom.Save (TargetXmlfile);

转载请注明原文地址:https://www.9cbs.com/read-20827.html

New Post(0)