What Design Pattern to use for collections of parsers

 
50   50
Jan 29, 2011
 
I have string and I need to pass it through different parsers and eventually get the processed string.
Lets say, I have
string s = "<input type='text' /> some text <span>hello</span> some text <select></select>";
Now, 1st parser will handle all "input" elements, 2nd parser will handle all "span" elements, and etc.
Each parser will do some work with the string and eventually the processed string will be returned.

Could anyone offer advise as to which Design Pattern I should use and/or how to do this in an 'elagant' way?

Thank you 



50   50
Feb 17, 2011
This seems like a use for the chain of responsibility.  Pass it to the first parser, and it will parse the parts it can and pass the rest to the second parser, and so forth.