Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Traceback (most recent call last):
- File "./xml.py", line 13, in <module>
- fn.text = values
- File "src/lxml/etree.pyx", line 1018, in lxml.etree._Element.text.__set__
- File "src/lxml/apihelpers.pxi", line 710, in lxml.etree._setNodeText
- File "src/lxml/apihelpers.pxi", line 698, in lxml.etree._createTextNode
- File "src/lxml/apihelpers.pxi", line 1491, in lxml.etree._utf8
- TypeError: Argument must be bytes or unicode, got 'list'
- values = base64.b64encode(values)
- Traceback (most recent call last):
- File "./xml.py", line 10, in <module>
- values = base64.b64encode(values)
- File "/usr/lib/python2.7/base64.py", line 54, in b64encode
- encoded = binascii.b2a_base64(s)[:-1]
- TypeError: b2a_base64() argument 1 must be string or buffer, not list
- <FileName>['1235362363151512d12d']</FileName>
- <FileName>1235362363151512d12d</FileName>
- #!/usr/bin/python
- from lxml import etree as ET
- root = ET.Element("alphanumeric")
- file = open("alphanumeric.txt", "r")
- for aline in file:
- values = aline.split()
- length = len(values)
- child = ET.SubElement(root,"child")
- fn = ET.SubElement(child, "FileName")
- fn.text = values
- tree = ET.ElementTree(root)
- tree.write("filename.xml")
- x = ET.parse("filename.xml")
- print ET.tostring(x, pretty_print=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement