<div dir="ltr"><div><div><div><div><div>Hello all.i have a quite big task, but i have a feeling it could be easily solved using python.<br></div>The thing is, i need to export the whole company DB(Postgresql) to an XML template provided by another company.<br>
</div>the template looks like this(just a fragment) : <br><br>?xml version="1.0" encoding="utf-8"?><br><PropertyDetailsRS><br> <Hotel><br> <AgencyId /><br> <AgencyCode /><br>
<GiataCode /><br> <Name /><br> <Descriptions><br> <Description Lang="DE"><br> <Common /><br> <ShortDescription /><br> <LongDescription /><br>
<Miscellaneous /><br> <Location /><br> <Interieur /><br> <ImportantRemark /><br> </Description><br> </Descriptions><br> <Category /><br> <Country /><br>
<Region /><br> <City /><br> <Zip /><br> <Address /><br> <AdditionalAddress /><br> <Telephone /><br> <Fax /><br> <Email /><br> <Url /><br> <DestinationAirports><br>
<IataCode Code="BKK" /><br> </DestinationAirports><br> </Hotel><br> <RoomList><br> <RoomGroup Id="" Code="" SeaView="" EN="" DE=""><br>
<RoomDescriptions><br> <RoomDescription Lang=""><br> <Description /><br> </RoomDescription><br> </RoomDescriptions><br> </RoomGroup><br> </RoomList><br>
<BoardList><br> <Board Id="" Code="" EN="" DE="" /><br> </BoardList><br> ...<br><br><br><br></div>i've never done anything like that.i'm familiar with psycopg2 module, also, i'm familiar with xml parsing(ElementTree, lxml).<br>
</div>is there some way to use the provided xml as a template, then parse all the data according to the template, what is the moyt pythonic way to do this?<br><br></div>Thx.<br><div><div><div><table class=""><tbody><tr><td class="">
<br></td></tr><tr><th class="" id="L2"><br></th><td class=""><br></td></tr><tr><th class="" id="L3"><br></th><td class=""><br></td>
</tr>
<tr>
<th class="" id="L4"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L5"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L6"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L7"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L8"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L9"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L10"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L11"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L12"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L13"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L14"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L15"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L16"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L17"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L18"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L19"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L20"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L21"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L22"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L23"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L24"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L25"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L26"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L27"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L28"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L29"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L30"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L31"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L32"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L33"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L34"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L35"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L36"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L37"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L38"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L39"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L40"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L41"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L42"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L43"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L44"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L45"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L46"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L47"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L48"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L49"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L50"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L51"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L52"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L53"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L54"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L55"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L56"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L57"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L58"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L59"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L60"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L61"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L62"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L63"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L64"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L65"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L66"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L67"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L68"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L69"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L70"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L71"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L72"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L73"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L74"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L75"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L76"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L77"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L78"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L79"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L80"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L81"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L82"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L83"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L84"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L85"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L86"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L87"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L88"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L89"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L90"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L91"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L92"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L93"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L94"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L95"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L96"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L97"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L98"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L99"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L100"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L101"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L102"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L103"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L104"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L105"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L106"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L107"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L108"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L109"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L110"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L111"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L112"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L113"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L114"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L115"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L116"><br></th>
<td class=""><br></td>
</tr>
<tr>
<th class="" id="L117"><br></th>
<td class=""><br></td></tr></tbody></table><br></div></div></div></div>