Created
February 9, 2015 21:41
-
-
Save poliarush/47a45ccdad02b10b61ea to your computer and use it in GitHub Desktop.
xml parsing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ApplicationState = None [ObjectifiedElement] | |
* xsi:noNamespaceSchemaLocation = 'ApplicationState.xsd' | |
appState = 'PRE_RACE' [StringElement] | |
eventId = 3625 [IntElement] | |
trackId = 713 [IntElement] | |
NextEventId = 3621 [IntElement] | |
PastEventId = 3627 [IntElement] | |
PRE_RACE | |
3625 | |
713 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xml = """ | |
<ApplicationState xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ApplicationState.xsd"> | |
<appState>PRE_RACE</appState> | |
<eventId>3625</eventId> | |
<trackId>713</trackId> | |
<NextEventId>3621</NextEventId> | |
<PastEventId>3627</PastEventId> | |
</ApplicationState> | |
""" | |
from lxml import objectify | |
root = objectify.fromstring(xml) | |
print(objectify.dump(root)) | |
print root.appState | |
print root.eventId | |
print root.trackId | |
# ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment