Posted 19 years ago by Todd Richardson - Integration Analyst, Foot Locker
Avatar
Do you have any examples anywhere that would show how to save a recorded macro to an xml file for reuse at a later time.

Thank you,
Todd

Comments (2)

Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
We don't have a sample of it but the documentation "General Features /
Macro Recording and Playback / Serializing and Deserializing Macros to XML" tells what methods to use to do it.


Actipro Software Support

Posted 19 years ago by Boyd - Sr. Software Developer, Patterson Consulting, LLC
Avatar
Here's the code I used to get the macro XML as a string (which could then be written out to a file):

MacroCommand macro = your_macro; // specify the macro to save to XML
MemoryStream memoryStream = new MemoryStream();
XmlTextWriter w = new XmlTextWriter(memoryStream, System.Text.Encoding.Unicode);
macro.WriteToXml(w);
w.Flush();
memoryStream.Position = 0;
StreamReader r = new StreamReader(memoryStream, System.Text.Encoding.Unicode);
string xmlOutput = r.ReadToEnd(); // Here's your XML text
w.Close();
r.Close();
memoryStream = null;
Likewise... here's the code I used to load a macro from an XML string

string xmlText = your_macro_xml_data; // specify the XML text
MemoryStream memoryStream = new MemoryStream();
StreamWriter w = new StreamWriter(memoryStream, System.Text.Encoding.Unicode);
w.Write(xmlText);
w.Flush();
memoryStream.Position = 0;
XmlTextReader r = new XmlTextReader(memoryStream);
MacroCommand macro = new MacroCommand();
macro.ReadFromXml(r);
w.Close();
r.Close();
memoryStream = null;
This was my first attempt at using MemoryStream or XmlTextReader, so there are likely more efficient ways to do this. I welcome any comments.

[Modified at 10/27/2005 07:39 AM]
The latest build of this product (v24.1.0) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.