I am really new to Python and I have the following .xml file:
<A>
<B>
<C>NUM123456</C>
<D>
<E>123</E>
<F>Spam</F>
<G>Apple</G>
</D>
<D>
<E>456</E>
<F>Egg</F>
<G>Orange</G>
</D>
<D>
<E>789</E>
<F>Bacon</F>
<G>Strawberry</G>
</D>
<D>
<E>0AB</E>
<F>Cheese</F>
<G>Cherry</G>
</D>
</B>
</A>
I am trying to take just some part of it so that the new .xml file would be:
<A>
<B>
<C>NUM123456</C>
<D>
<E>456</E>
<F>Egg</F>
<G>Orange</G>
</D>
<D>
<E>0AB</E>
<F>Cheese</F>
<G>Cherry</G>
</D>
</B>
</A>
I am trying to use the .xpath, but it will only start taking writing the new .xml file once it found the distinct node. In other words, node <A> <B> and <C> are not included in the new .xml file. Can anybody help?
Thanks!
You need to put in the right criteria–I based this filter on the text values from your examples:
Run it like this:
to get your desired output.