diff --git a/sosci2word/_SoSci2Word.mm b/sosci2word/_SoSci2Word.mm index a801bf9..f2af923 100644 --- a/sosci2word/_SoSci2Word.mm +++ b/sosci2word/_SoSci2Word.mm @@ -61,7 +61,7 @@ - + @@ -195,7 +195,8 @@ - + + @@ -224,10 +225,42 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -453,8 +486,7 @@ Modul python-doxc

- - + @@ -474,8 +506,7 @@ Beim Schreiben wird der bestehende Content verworfen und durch einen einzigen Run ersetzt, der den gegebenen Text ohne weitere Formatierungen enthält

- - +
@@ -489,8 +520,7 @@ Modul elementtree

- - + @@ -509,8 +539,7 @@ >>> unescape('"') '"' - - +
diff --git a/sosci2word/sosci2word.py b/sosci2word/sosci2word.py index 6c9cb13..1d37ad4 100644 --- a/sosci2word/sosci2word.py +++ b/sosci2word/sosci2word.py @@ -21,13 +21,28 @@ def convertSosci2Word(): # root = ElementTree.parse(SOSCI_XML).getroot() - for child in root: - print(child.tag, child.attrib) + for section in root.findall('section'): + title = section.find('title') + id_prefix = getSpecificID(section) + print("Section: Title »%s« Prefix=%s" % (title.text,id_prefix)) + + for question in section.findall('question'): + title = question.find('title').text + desc = question.find('description').text + qustionType = question.find('class').text + id_suffix = getSpecificID(question) + id_suffix = int(id_suffix) + questionID = "%s%02d" % (id_prefix, id_suffix) + print("Question: ID=%s desc=%s type=%s title=%s " % (questionID, desc, qustionType, title)) +# Hilsmittel für SoSci-XML: extrahiert ein ID-Element, das eingeschachtelt in liegt +def getSpecificID(element): + attribspecific = element.find('attributes.specific') + return next(attr.text for attr in attribspecific.findall('attr') if attr.get('id') == 'id')