In SystemWeaver, certain XML attributes, such as test sequences or historical data, may be stored in a compressed format using base64 encoding and ZLib compression. If you encounter a tag like the following:
<Attribute sid="TSQL" binary="True"> eJzdVdsOwUAQPZ+y8QPiTlISwYPEg+AHiqUNilqX+HpnB0GimngRm2a2OzNnzsyZPtTDCBo7GAz5... </Attribute>
You can easily decode and decompress it using the ZDecompressToString()
method provided in SystemWeaver.Common.Internal.SWCompression
. Here's a step-by-step guide to extract and read its content.
0. Extract the Base64 Content
Start by copying the content inside the <Attribute>
tag (excluding the XML wrapper):
string encodedString = "eJzdVdsOwUAQPZ+y8QPiTlISwYPEg+AHiqUNilqX+HpnB0GimngRm2a2OzNnzsyZPtTDCBo7GAz53mLPM8JEYgo9+E+5LqaoI4McrQEvsfJRd6+o0VQCy5A4jY3cB1jjSESbXo5+9iXioUl+g5CxiH4fsUxgJzUIpHPAzmdazC4KY05l+Fi8ZXut99DBiZ21RDUrBsK3x5J+QyrSEC1yrfhY7YaZa9X76LPSJNX5VNUtUTrB4qba56k4j8ZMbobTxUQq9g0x581n1iKsFwgmlJ2NJRaRyZ7zLzZ0vPXXONDin2yskLqx//jyRUd0lBzRUXZER8URHVVHdNT+TEc28T//OWu5LuVfezw=";
1. Decode the Base64 String
Decode the base64 string into a byte array:
byte[] compressedData = Convert.FromBase64String(encodedString);
2. Decompress the ZLib Content
Use the SystemWeaver internal compression utility to decompress the byte array into a readable string:
string decompressedString = SWCompression.ZDecompressToString(compressedData);
Note: Make sure to include the appropriate using directive or reference to SystemWeaver.Common.Internal.SWCompression . |
Example Output
Once decompressed, the string will typically represent a structured XML snippet, like this:
<TestSequences LastSeqId="1"> <TestSequence LastId="9" SeqId="1"> <Step> <RowID>1</RowID> <Action>Press the hazard button</Action> <ExpectedResult/> <Comments/> </Step> <Step> <RowID>2</RowID> <Action>Check that left turn signal light is blinking</Action> <ExpectedResult>whatever</ExpectedResult> <Comments/> </Step> <!-- Additional steps... --> </TestSequence> </TestSequences>
This XML can now be parsed and processed using any standard XML parser.