Exemplo n.º 1
0
 public static string xmlFormat(this string xml, int indentation, char indentChar)
 {
     XmlDocument doc = new XmlDocument();
     doc.Load(xml.xmlReader());
     var stringWriter = new StringWriter();
     var xmlWriter = new XmlTextWriter(stringWriter);
     xmlWriter.Formatting = Formatting.Indented;
     xmlWriter.Indentation = indentation;
     xmlWriter.IndentChar = indentChar;
     xmlWriter.field("encoding", new UTF8Encoding()); //DC: is there another to set this			
     doc.Save(xmlWriter);
     return stringWriter.str();
 }
Exemplo n.º 2
0
 public static string xmlCreateXSD(this string xml)
 {
     try
     {
         "Creating XSD from XML".info();
         var dataSet = new DataSet();
         dataSet.ReadXml(xml.xmlReader());
         var stringWriter = new StringWriter();
         XmlTextWriter xmlTextWriter = new XmlTextWriter(stringWriter);
         xmlTextWriter.Formatting = Formatting.Indented;
         xmlTextWriter.field("encoding", new UTF8Encoding());	//DC: is there another to set this
         //xmlTextWriter.WriteStartDocument();
         dataSet.WriteXmlSchema(xmlTextWriter);
         xmlTextWriter.Close();
         stringWriter.Close();
         return stringWriter.ToString();
     }
     catch (Exception ex)
     {
         ex.log("in createXSDfromXmlFile");
         return "";
     }
 }