比如一个xml的字符串为"<?xml version='1.0' encoding='UTF-8'?><Element><book ISBN='1-861001-57-5'>
<title>Pride And Prejudice</title>
<price>19.95</price></book></Element>"
如何让此格式混乱的字符串,能够按xml格式展示出来:
"<?xml version='1.0' encoding='UTF-8'?>
  <Element>
     <book ISBN='1-861001-57-5'>
        <title>Pride And Prejudice</title>
        <price>19.95</price>
    </book>
  </Element>
应该有类似的函数,不会自己写代码进行解析处理吧.
请指点下.谢谢

解决方案 »

  1.   

    我的意思就是让一个字符串(可能就是一行字符串,中间没有任何空格和回车.或者是多行,中间有若干空格
    和回车)能够按照xml的格式有序展示到界面,使人能看的清晰一些.
      

  2.   

    你在什么地方显示的???
    你可以使用XSLT来格式化XML
    或者在写XML的时候参考XmlWriterSettings 类
      

  3.   

    比如是别人写的xml.我不能确保他是按照xml格式来写的.我要把这些字符串展示在Form上.
      

  4.   

    http://dotnet.aspx.cc/article/95f0b01b-edf2-4fb6-a484-a5d7cb309195/read.aspx
      

  5.   

    using System.Xml;
    using System.IO;//...
            {
                XmlDocument document = new XmlDocument();
                string xml = "<?xml version='1.0' encoding='UTF-8'?><Element>" +
                    "<book ISBN='1-861001-57-5'><title>Pride And Prejudice</title>" +
                    "<price>19.95</price></book></Element>";
                document.LoadXml(xml);
                MemoryStream ms = new MemoryStream();
                document.Save(ms);
                ms.Position = 0;
                byte[] buffer = new byte[ms.Length];
                ms.Read(buffer, 0, buffer.Length);
                ms.Close();
                ms.Dispose();
                document = null;
                Console.WriteLine(Encoding.UTF8.GetString(buffer));
            }
    //...
    }
      

  6.   

    老大,怎么都是非法操作,呵呵!非法操作:没有找到您想要的数据。
    Index #0 Message: 操作必须使用一个可更新的查询。 Native: -198839259 Source: Microsoft JET Database Engine SQL: 3073 
      

  7.   

    http://dotnet.51aspx.com/article/95f0b01b-edf2-4fb6-a484-a5d7cb309195/read.aspx
      

  8.   

    <table>
    <user>
      <id>1</id>
      <username>admin</username>
      <password>admin123</password>
    </user>
    <user>
      <id>2</id>
      <username>muyuqing</username><password>19891024</password>
    <user>
    <table>
    以上是一段字符串,如何将此段字符串里的内容存放到List<T>集合中或者说是转换成List<T>集合?