我建了 一个 htm 的模板 ,单个字符的 我解析好了 
现在就是想问下 像这样的该如何解析呢{dede:datalist row='2'}
 <li>{field.fieldname1/} - {field.fieldname2/} ...</li>
{/dede:datalist}

解决方案 »

  1.   

    单个字符需要解析??不就是一Replace吗?
      

  2.   

     str = str.Replace("{rui:title}", this.TextBox1.Text);//替换Title这样的替换好了 {dede:datalist row='2'}
     <li>{field.fieldname1/} - {field.fieldname2/} ...</li>
    {/dede:datalist}这样的如何
      

  3.   

    乱搞。
    直接aspx就得得了。
      

  4.   


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.IO;
    namespace ConsoleApplication13
    {
        class Program
        {
            static void Main(string[] args)
            {
                string  pr_loop="0";
                string Mass_Primary="";
                string Mass_Inserted="";
                string Mass_Content="{rui:artlist,row=5}";            string RuiName;
                string  RuiVvlue;
                int pos1 = Mass_Content.IndexOf('{');
                int pos2 = Mass_Content.LastIndexOf('}');
                if (pos2 < 1)
                {
                    Console.WriteLine("标签格式错误");
                }
                Mass_Primary = Mass_Content.Substring(1, pos2 - 1);
                int n = pos2 - pos1 - 1;
                if (n > 0)
                {
                    Mass_Inserted = Mass_Content.Substring(pos1 + 1, n);
                }
                string[] _mass_p = Mass_Inserted.Split(',');
                if (_mass_p[0].Equals("rui:artlist"))
                {
                    pr_loop = "1";
                }
                else
                {
                    Console.WriteLine("标签不是以 rui: 开始的!");
                }
                int t = _mass_p.Length;
                for (int i = 1; i < t; i++)
                {
                    string s = _mass_p[i];
                    int pos = s.IndexOf('=');
                    if (pos == 0)
                    {
                        continue;
                    }
                    RuiName = s.Substring(0, pos).Trim();
                    RuiVvlue = s.Substring(pos + 1).Trim();
                    switch (RuiName)
                    {
                        case"row":
                            pr_loop = RuiVvlue;
                            break;
                        default:
                            pr_loop = "eee";
                            break;
                    }
                    
                }
                Console.WriteLine(pr_loop);
                Console.ReadKey();        }
           
        }
    }
      

  5.   

    你可以参考源代码
    http://www.codeproject.com/KB/cs/adertemplateengine.aspx
    或者
    NVelocityhttp://nvelocity.sourceforge.net/里面支持更多指令