I have an XML file as:
<a>
<b>
<c>
<condition>
....
</condition>
</c>
</b>
</a>
I have another XML in string type as :
<condition>
<comparison compare="and">
<operand idref="Agent" type="boolean" />
<comparison compare="lt">
<operand idref="Premium" type="float" />
<operand type="int" value="10000" />
</comparison>
</comparison>
</condition>
I need to comment the 'condition block' in the first xml and then append this second xml in place of it. I did not try to comment the first block but tried to append the second xml in the first. I am able to append it to it but I am getting the '<' and '>' as < ; and > ; respectively as
<a>
<b>
<c>
<condition>
....
</condition>
<condition>
<comparison compare="and">
<operand idref="Agent" type="boolean"/>
<comparison compare="lt">
<operand idref="Premium" type="float"/>
<operand type="int" value="10000"/>
</comparison>
</comparison>
</condition>
How do I convert this back to < and > rather than lt and gt?
And how do I delete or comment the <condition> block of the first xml below which I will append the new xml?
tree = ET.parse('basexml.xml') #This is the xml where i will append
tree1 = etree.parse(open('newxml.xml')) # This is the xml to append
xml_string = etree.tostring(tree1, pretty_print = True) #converted the xml to string
tree.find('a/b/c').text = xml_string #updating the content of the path with this new string(xml)
I converted the 'newxml.xml' into a string 'xml_string' and then appended to the path a/b/c of the first xml