2

I was wondering how it is possible to escape special characters in an xml.

The following example fails sadly:

xml ="""<?xml version="1.0" encoding="UTF-8" ?>
    <Render value="a &lt b"/>
"""
import xml.etree.ElementTree as ET
p = ET.fromstring(xml)

Output:
ParseError: not well-formed (invalid token): line 2, column 28

What is the easiest way round this problem?

1 Answer 1

1

Wrong escaping!

Try

<Render value="a &lt; b"/>

And everything works fine!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.