import argparse import xml.etree.ElementTree as ET parser = argparse.ArgumentParser() parser.add_argument('-i', dest='input_file', required=True) parser.add_argument('--author', dest='author', required=True) parser.add_argument('--publishing_year', dest='publishing_year', required=True) parser.add_argument('--title', dest='title', required=True) args = parser.parse_args() element_tree = ET.parse(args.input_file) text_node = element_tree.find('text') text_node.set('author', args.author) text_node.set('publishing_year', args.publishing_year) text_node.set('title', args.title) element_tree.write(args.input_file)