[python-uk] Merging DOM trees

Matt Hamilton matth at netsight.co.uk
Thu Jan 6 16:53:07 CET 2011


Hi All,
  Anyone know if there is a simple built-in way in which to overlay one XML DOM tree on top of another? Other than traversing both and creating nodes on the target DOM that existing in the source?

I'm currently using minidom, but could use something else... this is for a silly little script though, so don't really want to go through compiling some big esoteric XML library if I don't have to.

e.g.

Dom A:

<A>
  <B>
    <C>foo</C>
    <C>bar</C>
  </B>
</A>

overlaid on:

<A>
  <B></B>
  <D>baz</D>
</A>

would give:

<A>
  <B>
    <C>foo</C>
    <C>bar</C>
  </B>
  <D>baz</D>
</A>


-Matt

-- 
Matt Hamilton                                         matth at netsight.co.uk
Netsight Internet Solutions, Ltd.          Business Vision on the Internet
http://www.netsight.co.uk                               +44 (0)117 9090901
Web Design | Zope/Plone Development and Consulting | Co-location | Hosting



More information about the python-uk mailing list