How to insert a child subelement in Python ElementTree
<p>My xml :-</p>

<pre><code>&lt;users&gt;
&lt;/users&gt;
</code></pre>

<p>i need to just append a child element :-</p>

<pre><code>&lt;users&gt;
&lt;user name="blabla" age="blabla" &gt;&lt;group&gt;blabla&lt;/group&gt;
&lt;/users&gt;
</code></pre>

<p>My code giving some error :(</p>

<pre><code>import xml.etree.ElementTree as ET
doc = ET.parse("users.xml")
root_node = doc.find("users")
child = ET.SubElement(root_node, "user")
child.set("username","srquery")
group  = ET.SubElement(child,"group")
group.text = "fresher"
tree = ET.ElementTree(root_node)
tree.write("users.xml")
</code></pre>

<p>I missed out "append" , but i don't have idea where to add that. Thanks in advance.</p>
