Apertium

Write a script to comment out entries in an XML file

Given an XML file on standard input like:

<e><p><l>foo</l><r>bar</r></p></e>
<e><p><l>baz</l><r>baa</r></p></e>
<e><p><l>foa</l><r>yuo</r></p></e>
<e><p><l>gae</l><r>yaa</r></p></e>

And a list in a file (filename given as the first argument to the script) like

foo:
:yaa

Print the following XML file to standard output:

<!--<e><p><l>foo</l><r>bar</r></p></e>-->
<e><p><l>baz</l><r>baa</r></p></e>
<e><p><l>foa</l><r>yuo</r></p></e>
<!--<e><p><l>gae</l><r>yaa</r></p></e>-->

The task should also take into account:

tags:

foo<n>: = foo<s n="n"/>

spaces:

foo bar<n>: = foo<b/>bar<s n="n"/>

grouped elements:

foo# bar<n>: = foo<g><b/>bar</g><s n="n"/>

You can use any programming language you want, but Python is recommended.

Task tags

  • python
  • xml

Students who completed this task

RTCoder, svineet

Task type

  • code Code
close

2015