Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Python by Neerav Kumar ( 15 years ago )
# python
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from elementtree.ElementTree import parse
>>> tree = parse("./PlaceCodes.xml")
>>> elem = tree.getroot()
>>> list(elem)
[<Element {http://schemas.microsoft.com/sqlserver/2004/bulkload/format}RECORD at b72c07cc>, <Element {http://schemas.microsoft.com/sqlserver/2004/bulkload/format}ROW at b72c0a8c>]
>>> p=tree.find("ROW/COLUMN")
>>> list(p)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not iterable
>>> p=tree.find("RECORD")
>>> list(p)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not iterable
>>> p=tree.findall("COLUMN")
>>> list(p)
[]
>>> list(p)
[]
>>> p=tree.findall("COLUMN")
>>> p=tree.findall("RECORD")
>>> list(p)
[]
>>> elem = tree.getroot()
>>> list(elem)
[<Element {http://schemas.microsoft.com/sqlserver/2004/bulkload/format}RECORD at b72c07cc>, <Element {http://schemas.microsoft.com/sqlserver/2004/bulkload/format}ROW at b72c0a8c>]
>>> list(elem.items())
[]
>>> items=elem.items() 
>>> list(items)
[]
>>> elem = tree.getroot()
>>> list(elem)
[<Element {http://schemas.microsoft.com/sqlserver/2004/bulkload/format}RECORD at b72c07cc>, <Element {http://schemas.microsoft.com/sqlserver/2004/bulkload/format}ROW at b72c0a8c>]
>>> print elem
<Element {http://schemas.microsoft.com/sqlserver/2004/bulkload/format}BCPFORMAT at b72c078c>
>>> list(elem)
[<Element {http://schemas.microsoft.com/sqlserver/2004/bulkload/format}RECORD at b72c07cc>, <Element {http://schemas.microsoft.com/sqlserver/2004/bulkload/format}ROW at b72c0a8c>]
>>> print elem.find("RECORD")
None
>>> print elem.findtext("RECORD")
None
>>> print elem.findtext("RECORD")
None
>>> list(elem)
[<Element {http://schemas.microsoft.com/sqlserver/2004/bulkload/format}RECORD at b72c07cc>, <Element {http://schemas.microsoft.com/sqlserver/2004/bulkload/format}ROW at b72c0a8c>]
>>> iter=elem.iter()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: _ElementInterface instance has no attribute 'iter'
>>> iter=elem.getiterator()
>>> list(iter)
[<Element {http://schemas.microsoft.com/sqlserver/2004/bulkload/format}BCPFORMAT at b72c078c>, <Element {http://schemas.microsoft.com/sqlserver/2004/bulkload/format}RECORD at b72c07cc>, <Element {http://schemas.microsoft.com/sqlserver/2004/bulkload/format}FIELD at b72c080c>, <Element {http://schemas.microsoft.com/sqlserver/2004/bulkload/format}FIELD at b72c08ec>, <Element {http://schemas.microsoft.com/sqlserver/2004/bulkload/format}FIELD at b72c09ac>, <Element {http://schemas.microsoft.com/sqlserver/2004/bulkload/format}ROW at b72c0a8c>, <Element {http://schemas.microsoft.com/sqlserver/2004/bulkload/format}COLUMN at b72c0b2c>, <Element {http://schemas.microsoft.com/sqlserver/2004/bulkload/format}COLUMN at b72c0c2c>, <Element {http://schemas.microsoft.com/sqlserver/2004/bulkload/format}COLUMN at b72c0b0c>]
>>> for node in iter:
...     for child in node:
...             print child.get("NAME")
... 
None
None
None
None
None
PLT_COD
PLC_COD
PLC_TXT

 

Revise this Paste

Your Name: Code Language: