What's the real difference between filter and codec and which I have to use?

Should I use a codec or filter for this?

While it would make some sense to have a codec for processing XML there is no such thing. There is however an xml filter.

Is there a codec/filter/something_else that does what I need or should I write my own xml parser to my xml format?

Use the xml filter. Its xpath option should be useful to you.