0
for fgc in repair_parts_fgc_group.find('./' + junk + 'some_fancy_code_and_stuff'):
      groupcode = str(fgc[:2])
      figref = str(fgc[2:4])
      item_number = str(fgc[-4:])
repairPartsXml[noOfTables] += '<fncgrp>\n'
repairPartsXml[noOfTables] += '<fnccode>%s</fnccode>\n' % (groupcode)
repairPartsXml[noOfTables] += '<fnctitle>%s</fnctitle>\n' % (title)
repairPartsXml[noOfTables] += '<figref idref="%s">\n' % (figref)
repairPartsXml[noOfTables] += '</fncgrp>\n'

I am building a script that will convert the data in one xml file into another with a different DTD. There is a specific code that gets parsed into three different parts that I can use in the tags.

When I added this section in I received a error message stating

TypeError: not all arguments converted during string formatting

I am new to Python so if any one could help that would be great. Thank you.

  • It helps to include the full traceback error message. It will tell us on exactly which line the `TypeError` is occurring. – unutbu Apr 08 '16 at 16:10
  • You might want to check out the xml module: https://docs.python.org/2/library/xml.etree.elementtree.html#module-xml.etree.ElementTree – Peter Apr 08 '16 at 16:10
  • where 'title' comes from? – Oleg Gryb Apr 08 '16 at 16:15
  • 1
    Why reinvent the wheel? Use an existing [XML parser](http://stackoverflow.com/questions/1912434/how-do-i-parse-xml-in-python) and be done with this task in seconds... – Akshat Mahajan Apr 08 '16 at 16:26

1 Answers1

0

The easiest way I found to fix my issue was as follows;

technical_manual_functional_group_code = repair_parts_fgc_group.find('./' + junk + 'technical_manual_functional_group_code').text


 repairPartsXml[noOfTables] += '<figure id="fig%s">\n' % (technical_manual_functional_group_code[2:5])

repairPartsXml[noOfTables] += '<fnccode>%s</fnccode>\n' % (technical_manual_functional_group_code[0:2])