Uma maneira alternativa com python
e ElementTree
:
from __future__ import print_function
import sys
import xml.etree.ElementTree as ET
def main():
if len(sys.argv) < 3:
print("usage:", sys.argv[0], "input", "output")
sys.exit(1)
tree = ET.parse(sys.argv[1])
root = tree.getroot();
src = root.find(".//*[@name='scc_title']")
dst = root.find(".//*[@name='scc_comments']")
if src is not None and dst is not None:
dst.text += src.text
tree.write(sys.argv[2])
else:
if src is None:
print("Failed to find 'scc_title' attribute", file=sys.stderr)
if dst is None:
print("Failed to find 'scc_comments' attribute", file=sys.stderr)
sys.exit(1)
if __name__ == "__main__":
main()