日期:2014-05-17  浏览次数:20678 次

求帮忙~!
本帖最后由 lisiwen8 于 2012-11-26 15:43:08 编辑 对XML文件的编辑 文本框输入
<?xml version="1.0" encoding="ISO-8859-1"?>
<1><to>George</to><2><from>John</from><heading>Reminder</heading></2><body>Don't forget the meeting!</body></1>

点击编辑后文本框显示:
<?xml version="1.0" encoding="ISO-8859-1"?>
  <1>
  <to>George</to>
  <2>
     <from>John</from>
     <heading>Reminder</heading>
  </2>
  <body>Don't forget the meeting!</body>
  </1>

<1><2>代表标签 
------最佳解决方案--------------------

private void button1_Click(object sender, EventArgs e)
        {
            textBox1.Text = Regex.Replace(textBox1.Text, @"\x20*(</?\d+>
------其他解决方案--------------------
</[a-zA-Z]+>)", "$1\r\n");
        }


------其他解决方案--------------------
引用:
C# code?



12345

private void button1_Click(object sender, EventArgs e)         {             textBox1.Text = Regex.Replace(textBox1.Text, @"\x20*(</?\d+>