1. 程式人生 > >XmlDocument.LoadXML+如何構造xml字串

XmlDocument.LoadXML+如何構造xml字串

            tringBuilder sb = new StringBuilder();
            sb.Append(" <?xml version=/"1.0/"?> ");
            sb.Append(" <root> ");
            sb.Append(" <test value=/"| /"/> ");
            sb.Append(" </root> ");
            XmlDocument d = new XmlDocument();
            try
            {
                d.LoadXml(sb.ToString());
                MessageBox.Show("OK");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                d = null;
                sb = null;
            }