[Tutor] Issues Parsing XML

Moos Heintzen iwasroot at gmail.com
Fri Mar 13 02:40:36 CET 2009


I'm a little bored, so I wrote a function that gets <finding> elements
and puts them in a dictionary. Missing elements are just an empty
string.

http://gist.github.com/78385

Usage:
>>> d = process_finding(findings[0])
>>> ", ".join(map(lambda e: d[e], elements))
u'V0006310, NF, , , GD, 2.0.8.8, TRUE, DTBI135-Scripting\nof Java
applets -\nRestricted, 2'

Now for a <finding> of 9 elements:
>>> d = process_finding(findings[1])
>>> ", ".join(map(lambda e: d[e], elements))
u'V0006311, O, The
value:\nSoftware\\Policies\\Microsoft\\Windows\\CurrentVersion\\Internet\nSettings\\Zones\\4\\1A00
does not exist.\n\n, The
value:\nSoftware\\Policies\\Microsoft\\Windows\\CurrentVersion\\Internet\nSettings\\Zones\\4\\1A00
does not exist.\n\n, GD, 2.0.8.8, TRUE, DTBI136-User\nAuthentication -
Logon -\nRestricted, 2'

The map() function just applies the dictionary to each element in the
elements list. You can reorder them anyway you want.

You're welcome :)

Moos


More information about the Tutor mailing list