Necati DEMiR wrote:
> I wanna ask a question about inserting childs.
> How can i insert a child?
what toolkit are you using?
> For example, i have a xml file as the following;
>
> <?xml version="1.0" encoding="UTF-8" >
> <results>
> <result>
> <node1>test1</node1>
> <node2>tes2</node2>
> </result>
> </results>
>
> And i want the output as the following after inserting nodes
>
> <?xml version="1.0" encoding="UTF-8" >
> <results>
> <result>
> <node1>test1</node1>
> <node2>tes2</node2>
> </result>
> <result>
> <node1>qwe</node1>
> <node2>rty</node2>
> </result>
>
> </results>
ElementTree version:
from elementtree import ElementTree as ET
doc = ET.parse("mydoc.xml")
results = doc.getroot()
result = ET.SubElement(results, "result")
ET.SubElement(result, "node1").text = "qwe"
ET.SubElement(result, "node2").text = "rty"
</F>
_______________________________________________
XML-SIG maillist - [email protected]
http://mail.python.org/mailman/listinfo/xml-sig