I need to traverse the XML tree to add sub element when the value is less than 5. For example, this XML can be modified into
<?xml version="1.0" encoding="UTF-8"?>
<A value="45">
<B value="30">
<C value="10"/>
<C value ="20"/>
</B>
<B value="15">
<C value = "5" />
<C value = "10" />
</B>
</A>
this XML.
<?xml version="1.0" encoding="UTF-8"?>
<A value="45">
<B value="30">
<C value="10"/>
<C value ="20"/>
</B>
<B value="15">
<C value = "5"><D name="error"/></C>
<C value = "10" />
</B>
</A>
How can I do that with Python's ElementTree?
<D>child? Have you considered the option of adding an "error" attribute to the element with a problem?