So this is the xml output I require:
<?xml version="1.0" encoding="utf-8"?>
<fooList action="add" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<foo>
<bar>1</bar>
</foo>
</fooList>
I am using the xmltodict python library to generate this output from a dictionary. The only problem is when I try to add the fooList tag on the top, it copies the whole string to the closing tag when it should just end in fooList. Sample of that:
<?xml version="1.0" encoding="utf-8"?>
<fooList action="add" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<foo>
<bar>1</bar>
</foo>
</fooList action="add" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
python code:
entry = {
'<fooList action="add" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance': {
"foo": {
"bar": 1,
}
}
}
xml = xmltodict.unparse(entry, pretty=True)