nich
nich

Reputation: 83

python: print xml document

If I print xml document this way:

print(doc.toprettyxml(indent=' '*spaces, encoding='utf-8'))

I got this:

b'<?xml version="1.0" encoding="utf-8"?>\n<element att=""/>\n'

How can I get away the b' prefix and ' suffix ?

Upvotes: 0

Views: 386

Answers (1)

dusan
dusan

Reputation: 9273

Try using decode:

print(doc.toprettyxml(indent=' '*spaces, encoding='utf-8').decode('utf-8'))

Upvotes: 4

Related Questions