I am looking to create an expression tree by parsing xml using C#. The xml would be like the following:
<Expression>
<If>
<Condition>
<GreaterThan>
<X>
<Y>
</GreaterThan>
</Condition>
<Expression />
<If>
<Else>
<Expression />
</Else>
<Expression>
or another example...
<Expression>
<Add>
<X>
<Expression>
<Y>
<Z>
</Expression>
</Add>
</Expression>
...any pointers on where to start would be helpful.
Kind regards,
using System.Linq.Expressions; //in System.Core.dll
Expression BuildExpr(XmlNode xmlNode)
{ switch(xmlNode.Name)
{ case "Add":
{ return Expression.Add( BuildExpr(xmlNode.ChildNodes[0])
,BuildExpr(xmlNode.ChilNodes[1]));
}
/* ... */
}
}
我首先看一下DLR,它有一个已发布的表达式树机制。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.