Als blutiger Python-Anfänger habe ich eine für mich interessante, aber eben echt schwierige Aufgabe zu lösen: Wir verwalten Mobiles für ein paar Personen. Unser Mobile Device Management Programm hat folgendes Reporting:
Code: Alles auswählen
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<deviceManagementWebServiceResponse>
<messages>
<message>15 Device(s) returned.</message>
</messages>
<devices>
<device id="16">
<uuid>0765458d-8d1c-4b5d-934c-f14897def35d</uuid>
<principal>mwendlin</principal>
<clientId>1073741846</clientId>
<countryCode>46</countryCode>
<countryId>165</countryId>
<countryName>Sweden</countryName>
<details>
<entry>
<key>ImeiOrMeid</key>
<value>35721503047246101</value>
</entry>
</details>
<deviceCount>0</deviceCount>
<emailAddress>marcus.wendling@systeam.se</emailAddress>
<employeeOwned>false</employeeOwned>
<homeOperator>42IT</homeOperator>
<manufacturer>HTC</manufacturer>
<mdmManaged>false</mdmManaged>
<model>HTC HD mini T5555</model>
<name>mwendlin:WinMo:761055694</name>
<notifyUser>true</notifyUser>
<operator>42IT</operator>
<operatorId>27</operatorId>
<phoneNumber>761055694</phoneNumber>
<platform>Windows Mobile 6.5 Professional</platform>
<platformType>WINMO_6_5_PRO</platformType>
<regCount>0</regCount>
<regType>DEFAULT</regType>
<status>ACTIVE</status>
<statusCode>97</statusCode>
<userDisplayName>Marcus Wendling</userDisplayName>
<userFirstName>Marcus</userFirstName>
<userLastName>Wendling</userLastName>
<userUUID>49197f4e-c659-4b16-b43a-877c95d51354</userUUID>
</device>
</devices>
</deviceManagementWebServiceResponse>
Code: Alles auswählen
Firmenname;IMEI;Mobile Nr;
Fun&Work;89454957963543670;766432098;
Fun&Work;35721503047246101;761055694;
Fun&Work;53456213433509722;752210998;
Code: Alles auswählen
#!/usr/bin/env python
# -*- coding: utf8 -*-
#!/usr/bin/env python
import codecs
from xml.etree import ElementTree as et
files = file("devices.xml", "r")
etree = et.parse(files)
root_tag = etree.getroot()
for deviceslist in root_tag.findall("devices"):
for device in deviceslist.findall("device"):
uuid = device.find("uuid").text
Name = device.find("userDisplayName").text
print Name
print uuid
Code: Alles auswählen
<entry>
<key>ImeiOrMeid</key>
<value>35721503047246101</value>
</entry>
Vielen herzlich Dank schon im Voraus für Eure Hilfe!
Puemer