Script to parse xml data, compress the selected data & decompress them (--gzip & --gunzip compatible)
- Parse an XML document. Name of the file to parse should be given as the program argument. Here is an example file:
<author>O'Brien, Tim</author>
<title>MSXML3: A Comprehensive Guide</title>
<genre>Computer</genre>
<price>36.95</price>
<publish_date>2000-12-01</publish_date>
<description>The Microsoft MSXML3 parser is covered in
detail, with attention to XML DOM interfaces, XSLT processing,
SAX and more.</description>
<author>Galos, Mike</author>
<title>Visual Studio 7: A Comprehensive Guide</title>
<genre>Computer</genre>
<price>49.95</price>
<size> 22 </size>
<publish_date>2001-04-16</publish_date>
<last_description test=”1”>Microsoft Visual Studio 7 is explored in depth,
looking at how Visual Basic, Visual C++, C#, and ASP+ are
integrated into a comprehensive development
environment.</last_description>
- Find all elements with the attribute: test=”1” (nodes’ contents marked below).
<author>O'Brien, Tim</author>
<title>MSXML3: A Comprehensive Guide</title>
<genre>Computer</genre>
<price>36.95</price>
<publish_date>2000-12-01</publish_date>
<description>The Microsoft MSXML3 parser is covered in
detail, with attention to XML DOM interfaces, XSLT processing,
SAX and more.</description>
<author>Galos, Mike</author>
<title>Visual Studio 7: A Comprehensive Guide</title>
<genre>Computer</genre>
<price>49.95</price>
<size> 22 </size>
<publish_date>2001-04-16</publish_date>
<last_description test=”1”>Microsoft Visual Studio 7 is explored in depth,
looking at how Visual Basic, Visual C++, C#, and ASP+ are
integrated into a comprehensive development
environment.
</last_description>
- Compress/Decompress the contents of those elements using ‘gzip’, based on the command line options ‘--gzip’ and ‘--gunzip’ respectively. Compression should apply only to those elements – marked with the “test” attribute. The rest of the XML file should remain the same as the original. And the generated file should be still valid XML. Name of the generated file could be hardcoded in the program. For example, the above input could produce:
[[gziped content of the element text. Maybe base64 encoded?]]
<author>Galos, Mike</author>
<title>Visual Studio 7: A Comprehensive Guide</title>
<genre>Computer</genre>
<price>49.95</price>
<size> 22 </size>
<publish_date>2001-04-16</publish_date>
<last_description test=”1”>
[[gziped content of the elment text. Maybe base64 encoded?]]
</last_description>
-
Bonus: send the resulted file to a given URL as a POST request. Use this URL to test that your post works: http://posttestserver.com/post.php Take a look at this URL for the how-to details: http://www.posttestserver.com
-
It should be possible to get the original document after passing it thought the application twice, first with ‘--gzip’ and then with ‘--gunzip’ arguments.
-
No extra files should be generated by the program. You may use temporary files if you need to, but make sure they are gone by the time the program exits.
-
You may use any extra package and libraries you find useful. You are actually encouraged to do so, as we do not want you to spent too much time on this task ;)
-
It is important that your solution work correctly and adhere to all the requirement.