1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
public class XMLFactory
{
public XDocument CurrentDocument { get; set; }
public XMLFactory(string xmlDocumentString)
{
this.CurrentDocument = XDocument.Load(new StringReader(xmlDocumentString));
}
public string SaveToString()
{
string toReturn = string.Empty;
XmlWriterSettings xmlWriterSettings = new XmlWriterSettings();
xmlWriterSettings.Encoding = new UTF8Encoding();
StringBuilder sb = new StringBuilder();
using (XmlWriter writer = XmlWriter.Create(sb,xmlWriterSettings))
{
this.CurrentDocument.Save(writer);
}
toReturn = sb.ToString();
return toReturn;
}
} |
Partager