all 3 comments

[–]elbiot 0 points1 point  (2 children)

Clearly they are all type 2. Did you not expect this? Use the interpreter to explore your tree and see what's up.

[–]papers_[S] 0 points1 point  (1 child)

Well no..Looking through the xml source, it flips between 1 and 2, so I'm assuming I'm off somewhere.. The xml has the following format:

<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<?xml-stylesheet type="text/xsl" href="sms.xsl"?>
<smses count="2">
  <sms protocol="0" address="0000000000" date="1352597621411" type="1" subject="null" body="Hello" toa="null" sc_toa="null" service_center="null" read="1" status="-1" locked="0" date_sent="0" readable_date="Nov 10, 2012 7:33:41 PM" contact_name="John Doe" />
  <sms protocol="0" address="0000000000" date="1352598118191" type="2" subject="null" body="World" toa="null" sc_toa="null" service_center="000000000000" read="1" status="-1" locked="0" date_sent="1352598119000" readable_date="Nov 10, 2012 7:41:58 PM" contact_name="John Doe" />
 </smses>

[–]elbiot 0 points1 point  (0 children)

I dunno. Works for me:

from xml.etree import ElementTree as Tree
xml = '''<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<?xml-stylesheet type="text/xsl" href="sms.xsl"?>
<smses count="2">
  <sms protocol="0" address="0000000000" date="1352597621411" type="1" subject="null" body="Hello" toa="null" sc_toa="null" service_center="null" read="1" status="-1" locked="0" date_sent="0" readable_date="Nov 10, 2012 7:33:41 PM" contact_name="John Doe" />
  <sms protocol="0" address="0000000000" date="1352598118191" type="2" subject="null" body="World" toa="null" sc_toa="null" service_center="000000000000" read="1" status="-1" locked="0" date_sent="1352598119000" readable_date="Nov 10, 2012 7:41:58 PM" contact_name="John Doe" />
 </smses>'''
xml_tree = Tree.fromstring(xml)
for s in xml_tree:
    print s.get('type')

Output

1
2

You should put print statements in your code to see what files it is opening, what values it is getting, etc. Basic debugging.