How to parse xml S3 bucket in python

Viewed 740

Fail to parse xml from s3 bucket

This is response from S3 bucket:

<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
  <Name>example-bucket</Name>
  <Prefix>photos/2006/</Prefix>
  <Marker></Marker>
  <MaxKeys>1000</MaxKeys>
  <Delimiter>/</Delimiter>
  <IsTruncated>false</IsTruncated>

  <CommonPrefixes>
    <Prefix>photos/2006/February/</Prefix>
  </CommonPrefixes>
  <CommonPrefixes>
    <Prefix>photos/2006/January/</Prefix>
  </CommonPrefixes>
</ListBucketResult>

When I use this code to parse

import xml.etree.ElementTree as ET
root = ET.fromstring(data)
print root

The result is:

<Element '{http://s3.amazonaws.com/doc/2006-03-01/}ListBucketResult' at 0x7f8f38482110>

Result should not container "{http://s3.amazonaws.com/doc/2006-03-01/}"

0 Answers
Related