xml格式的string转换为dataset

System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        sb.AppendFormat("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
        sb.AppendFormat("<GWInfo>");
        sb.AppendFormat("<lachuzhi>{0}</lachuzhi>",this.TextBox1.Text);
        sb.AppendFormat("<daogao>{0}</daogao>",this.TextBox2.Text);
        sb.AppendFormat("</GWInfo>");
        DataSet ds = new DataSet();
        StringReader sr = new StringReader(sb.ToString());
        XmlTextReader xmlReader = new XmlTextReader(sr);
        ds.ReadXml(xmlReader);

你可能感兴趣的:(String)