I have a string(an expression) like this (A | B) & (C & D) | E,which should be converted into the following XML.

Code:
<Expression>
<Or /> 
<Expression>
<And /> 
<Expression>
<Or /> 
<QRef refID="A" /> 
<QRef refID="B" /> 
</Expression>
<Expression>
<And /> 
<QRef refID="C" /> 
<QRef refID="D" /> 
</Expression>
</Expression>
<QRef refID="E" /> 
</Expression>
I'm using XMLserialization for this and below is the layout of my class..

Code:
public class Expression
{
	 private string _or;                   
        [XmlElementAttribute(Form = XmlSchemaForm.Unqualified)]
        public string Or
        {
            get
            {
                return _or;
            }
            set
            {
                _or = value;
            }
        }

        private string _and;
        [XmlElementAttribute(Form = XmlSchemaForm.Unqualified)]
        public string And
        {
            get
            {
                return _and;
            }
            set
            {
                _and = value;
            }
        }

        private List<QRef> _qRef;
        [XmlElementAttribute("QRef", Form = XmlSchemaForm.Unqualified)]
        public List<QRef> QueryReference
        {
            get
            {
                return _qRef;
            }
            set
            {
                _qRef = value;
            }
        }

        private List<Expression> _expressions;
        [XmlElementAttribute("Expression")]
        public List<Expression> MyExpressions
        {
            get
            {
                return _expressions;
            }
            set
            {
                _expressions= value;
            }
        }
}
I'm planning to write a static recursive method inside the Expression class and populate the expression object with inner expression objects and then convert it into XML.Can someone please help me with the recursive method here please?

Note that i have a binding towards a legacy DTD which is making me doing this.Also the expression can vary in any length like for example it can be (A&B)|(C&D)|(E&F)&(G&H)...and so on.Inshort the expression string is a dynamic input and can vary in lenth and the operators between them.Also,please do suggest if there is a better way to achieve this.

Thanks,
Mmx