Closed kainagel closed 4 years ago
Ok, this I found myself:
for person, plan in plans:
matsimAttributes = person.find('attributes')
for matsimAttribute in matsimAttributes:
if matsimAttribute.attrib['name'] == 'age':
print( matsimAttribute.attrib, matsimAttribute.text )
Typical xml tree model where you get attributes as attrib
and text as `text'; only for the elements it seems that they are there "by themselves".
Additionally confusing because of "attribute(s)" in the matsim naming scheme.
I'm glad you were able to solve this. But I am also wondering if we should change how the attributes are surfaced in the API? I don't want it to be incorrect but I also want users to feel comfortable in the Python environment.
The Python API to be as "pythonic" as possible, meaning that the fact the event file is XML shouldn't overtly influence the API itself: rather, the data should be available in a way that feels natural to Python users. I will think this over! Thanks, Billy
On May 10 2020, at 11:52 am, kainagel notifications@github.com wrote:
Ok, this I found myself: for person, plan in plans: matsimAttributes = person.find('attributes') for matsimAttribute in matsimAttributes: if matsimAttribute.attrib['name'] == 'age': print( matsimAttribute.attrib, matsimAttribute.text ) Typical xml tree model where you get attributes as attrib and text as `text'; only for the elements it seems that they are there "by themselves". Additionally confusing because of "attribute(s)" in the matsim naming scheme. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub (%20http://quarantine.tu-berlin.de:32224/?dmVyPTEuMDAxJiZmNmUyYTgxM2ViN2I2ZWI4Yz01RUI3Q0VFNV8zNzk4OF8yMTZfMSYmN2Q1ZGNjM2ZkOTIxNGZjPTEyMjImJnVybD1odHRwcyUzQSUyRiUyRmdpdGh1YiUyRWNvbSUyRm1hdHNpbS12c3AlMkZtYXRzaW0tcHl0aG9uLXRvb2xzJTJGaXNzdWVzJTJGNSUyM2lzc3VlY29tbWVudC02MjYzMDE4MTc=), or unsubscribe (http://quarantine.tu-berlin.de:32224/?dmVyPTEuMDAxJiZmNmUyYTgxMGU1N2I3NGI3Yz01RUI3Q0VFNV8zNzk4OF8yMTZfMSYmMzliY2JjNGU0ZDIxN2VlPTEyMjImJnVybD1odHRwcyUzQSUyRiUyRmdpdGh1YiUyRWNvbSUyRm5vdGlmaWNhdGlvbnMlMkZ1bnN1YnNjcmliZS1hdXRoJTJGQUFLNFFSVVJWWDJTVzdVS0FZN0JWSERSUVoyT0ZBTkNORlNNNE01RFc3R0E=).
In xml, we have
How to you get to, say,
age
?