0

I need the following output in an XML

log="+ Passed Open the Website
"

Here is the relevant part of the code

var1 = '
'
var2 = f' + {res} {na}{var1}'
var2 = var2.replace('&', '&')
case = ET.SubElement(
    suite,
    "testcase",
    {
        "name": f"{na}",
        "log": f'{var2}'

I have tried .replace and escape but every time it shows this output.

log=" + Passed Load Home Page
"

How can I replace the &amp with &?

horcrux
  • 6,493
  • 6
  • 27
  • 40
Abhishek Rai
  • 1,912
  • 3
  • 11
  • 27

2 Answers2

2

If your output is 
 then it means that you are re-escaping.
Try to unescape before outputing it, e.g.:

var1 = unescape('
')
horcrux
  • 6,493
  • 6
  • 27
  • 40
0

With this:

text = text.replace("&", "&")
aldegalan
  • 410
  • 2
  • 12