I'm very new to Python, only read the Learn Python the Hard Way. But I think this is still way out of my scope. My skills are in XML/XSL, not Python. I need a little help to get started.
Overview: I need to add missing XML data (addition.xml) into a existing XML file (original.xml).
XML file (with the data that is missing): (addition.xml)
<profile>
<dog-list>
<dog>
<name>sally</dog>
<age>1</age>
</dog>
<dog>
<name>susie</dog>
<age>12</age>
</dog>
</dog-list>
<people-list>
<person>
<name>ue</name>
<age>25</age>
<gender>female</gender>
</person>
</people-list>
</profile>
XML data above adds to this XML file: (original.xml)
<profile>
<cat-list>
<cat>
<name>foo></name>
</cat>
<cat>
<name>bar</name>
<age>3</age>
</cat>
</cat-list>
<bird-list>
<bird>
<name>cricket</name>
<age>2</age>
</bird>
</bird-list>
<people-list>
<person>
<name>tyler</name>
<age>26</age>
</person>
</people-list>
<car-list>
<car>
<make>mitsubishi</make>
<model>evo x</model>
<year>2013</year>
</car>
</car-list>
</profile>
My expected output should be: --> the new (original.xml)
<profile>
<cat-list>
<cat>
<name>foo></name>
</cat>
<cat>
<name>bar</name>
<age>3</age>
</cat>
</cat-list>
<dog-list>
<dog>
<name>sally</dog>
<age>1</age>
</dog>
<dog>
<name>susie</dog>
<age>12</age>
</dog>
</dog-list>
<bird-list>
<bird>
<name>cricket</name>
<age>2</age>
</bird>
</bird-list>
<people-list>
<person>
<name>tyler</name>
<age>26</age>
</person>
<person>
<name>ue</name>
<age>25</age>
<gender>female</gender>
</person>
</people-list>
<car-list>
<car>
<make>mitsubishi</make>
<model>evo x</model>
<year>2013</year>
</car>
</car-list>
</profile>
What happens here is that data from the addition.xml is missing from the original.xml file. How do I go about adding data from addition.xml into the original.xml instead of creating a new file, overwriting it.
I look all over google and stackoverflow. I know that I could use ElementTree
but I have the foggiest idea how to create this result.
Any help is greatly appreciated!