Monday, 9 February 2015

Delete parent where child is (x), cloning tags to siblings



I have a big xml feed of items which i would like to edit so it would fit my webstore importer needs.


The structure looks like this:



<company>

<pricelist>
<category></category>
<subc></subc>

<item>
<price></price>
<image></image>
</item>

<item>
<price></price>
<image></image>
</item>

....

</pricelist>

<pricelist>
<category></category>
<subc></subc>

<item>
<price></price>
<image></image>
</item>

....

<item>
<price></price>
<image></image>
</item>

</pricelist>

....

</company>


What i would like to achieve here are two things:


I. Remove certain parent <pricelist> where it's child <category> is x (something).


II. Clone <category> and <subc> tags to all the sibling <item>s.



<item>
<category></category>
<subc></subc>
<price></price>
<image></image>
</item>

No comments:

Post a Comment