public void Write(IEnumerable <SharpRow> rows) { var settings = new System.Xml.XmlWriterSettings { Indent = true, Encoding = _encoding }; _writer = System.Xml.XmlWriter.Create(_dest, settings); _writer.WriteStartDocument(); foreach (var row in rows) { WriteRow(row); } if (_commentBlock.Count > 0) { WriteCommentBlock(); } while (_nodeStack.Count > 0) { _writer.WriteEndElement(); _nodeStack.Dequeue(); } _writer.WriteEndDocument(); _writer.Flush(); _writer = null; }
/// <summary> /// 序列化对象为xml字符串 /// </summary> /// <param name="obj">要序列化的对象</param> /// <returns>xml格式字符串</returns> public static string Serialize(this object obj) { if (obj == null) { return(""); } Type type = obj.GetType(); if (type.IsSerializable) { try { System.Text.StringBuilder sb = new System.Text.StringBuilder(); System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(type); XmlWriterSettings xset = new XmlWriterSettings(); xset.CloseOutput = true; xset.Encoding = Encoding.UTF8; xset.Indent = true; xset.CheckCharacters = false; System.Xml.XmlWriter xw = System.Xml.XmlWriter.Create(sb, xset); xs.Serialize(xw, obj); xw.Flush(); xw.Close(); return(sb.ToString()); } catch { return(""); } } else { return(""); } }
protected static void _StreamXMLPlainLevel(object obj, out SqlXml entry) { entry = SqlXml.Null; Dictionary <string, string> dRow = obj as Dictionary <string, string>; #region Row Output System.IO.MemoryStream ms = new System.IO.MemoryStream(); using (System.Xml.XmlWriter wr = System.Xml.XmlWriter.Create(ms)) { wr.WriteStartElement("Row"); foreach (KeyValuePair <string, string> kvp in dRow) { wr.WriteStartElement(kvp.Key); wr.WriteString(kvp.Value); wr.WriteEndElement(); } wr.WriteEndElement(); wr.Flush(); wr.Close(); } #endregion ms.Seek(0, System.IO.SeekOrigin.Begin); entry = new SqlXml(ms); }
private Boolean isExists() { System.Xml.XmlWriter writer = null; try { if (!File.Exists(FileName)) { System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings(); settings.Indent = true; writer = System.Xml.XmlWriter.Create(FileName, settings); writer.WriteStartDocument(); writer.WriteStartElement("WebAddresses"); writer.WriteEndElement(); writer.WriteEndDocument(); } } catch (Exception e) { PrintConsole.LOG(e.StackTrace, e.Message); return(false); } finally { if (writer != null) { writer.Flush(); writer.Close(); } } return(true); }
private void WriteListXML(List <DB.Visits> list, string path, string filename) { System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(path + @"\" + filename + ".xml"); writer.WriteStartDocument(); writer.WriteStartElement("Visits"); foreach (var i in list) { writer.WriteStartElement("Visit"); writer.WriteElementString("Patient", i.Patients.FIO); writer.WriteElementString("Doctor", i.Doctors.FullName); writer.WriteElementString("DateStart", i.DateStart.Date + ""); writer.WriteElementString("TimeStart", i.TimeStart + ""); writer.WriteElementString("Cost", i.Cost + ""); writer.WriteElementString("Exempt", i.Exempts.Name); writer.WriteElementString("Summa", i.Summa + ""); writer.WriteElementString("Comment", i.Comment); writer.WriteEndElement(); writer.Flush(); } writer.WriteEndElement(); writer.WriteEndDocument(); writer.Close(); }
public void Flush() { if (_writer != null) { _writer.Flush(); } }
private void WriteXml(DataSet oDataSet, string sName) { string sXmlPath = string.Empty; System.Xml.XmlWriterSettings oSettings = null; System.Xml.XmlWriter oXmlWriter = null; try { sXmlPath = this.WorkingFolder + sName + ".xml"; oSettings = new System.Xml.XmlWriterSettings(); oSettings.Indent = false; oSettings.CheckCharacters = false; //System.IO.MemoryStream oMemoryStream = new System.IO.MemoryStream(); //oXmlWriter = System.Xml.XmlWriter.Create(oMemoryStream, oSettings); oXmlWriter = System.Xml.XmlWriter.Create(sXmlPath, oSettings); oDataSet.WriteXml(oXmlWriter); oXmlWriter.Flush(); oXmlWriter.Close(); } catch (Exception ex) { throw ex; } finally { oSettings = null; oXmlWriter = null; } }
private void writeValues(System.IO.StringWriter oStringWriter) { System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings(); settings.Encoding = Encoding.UTF8; settings.ConformanceLevel = System.Xml.ConformanceLevel.Auto; System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(oStringWriter, settings); writer.WriteRaw("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); writer.WriteStartElement("report"); writer.WriteAttributeString("date", DateTime.Now.ToString("yyyyMMdd_HHmm")); foreach (var row in Current.Context.Report.GetResultElements()) { writer.WriteStartElement("result"); foreach (var col in row.GetColumnNames()) { writer.WriteStartElement("column"); writer.WriteAttributeString("name", col); writer.WriteString(row.GetColumnValue(col)); writer.WriteEndElement(); } writer.WriteEndElement(); } writer.WriteEndElement(); writer.Flush(); }
public void Execute(JSFunctionMetadata func) { output.WriteStartElement("Program"); Dump(func, 0, 0); output.WriteEndElement(); output.Flush(); }
public void Flush() { if (Writer == null) { DebugConsole.ThrowError("Cannot flush invalid XmlWriter"); return; } Writer.Flush(); }
} // End Function DownloadPdf public static string BeautifyXML(System.Xml.XmlDocument doc) { string strRetValue = null; System.Text.Encoding enc = System.Text.Encoding.UTF8; // enc = new System.Text.UTF8Encoding(false); System.Xml.XmlWriterSettings xmlWriterSettings = new System.Xml.XmlWriterSettings(); xmlWriterSettings.Encoding = enc; xmlWriterSettings.Indent = true; xmlWriterSettings.IndentChars = " "; xmlWriterSettings.NewLineChars = "\r\n"; xmlWriterSettings.NewLineHandling = System.Xml.NewLineHandling.Replace; //xmlWriterSettings.OmitXmlDeclaration = true; xmlWriterSettings.ConformanceLevel = System.Xml.ConformanceLevel.Document; using (System.IO.MemoryStream ms = new System.IO.MemoryStream()) { using (System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(ms, xmlWriterSettings)) { doc.Save(writer); writer.Flush(); ms.Flush(); writer.Close(); } // End Using writer ms.Position = 0; using (System.IO.StreamReader sr = new System.IO.StreamReader(ms, enc)) { // Extract the text from the StreamReader. strRetValue = sr.ReadToEnd(); sr.Close(); } // End Using sr ms.Close(); } // End Using ms /* * System.Text.StringBuilder sb = new System.Text.StringBuilder(); // Always yields UTF-16, no matter the set encoding * using (System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(sb, settings)) * { * doc.Save(writer); * writer.Close(); * } // End Using writer * strRetValue = sb.ToString(); * sb.Length = 0; * sb = null; */ xmlWriterSettings = null; return(strRetValue); } // End Function BeautifyXML
public static string ToXmlStatement(string statement) { System.Data.DataTable dt = new System.Data.DataTable(); using (System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection("context connection=true")) { SqlCommand cmd = new SqlCommand(statement, con); using (SqlDataAdapter ada = new SqlDataAdapter(cmd)) { ada.Fill(dt); } } StringBuilder sb = new StringBuilder(); System.Xml.XmlWriterSettings xws = new System.Xml.XmlWriterSettings(); xws.OmitXmlDeclaration = true; using (System.Xml.XmlWriter wr = System.Xml.XmlWriter.Create(sb, xws)) { wr.WriteStartElement("ResultSet"); for (int iRow = 0; iRow < dt.Rows.Count; iRow++) { wr.WriteStartElement("Record"); for (int iCol = 0; iCol < dt.Columns.Count; iCol++) { wr.WriteStartElement(dt.Columns[iCol].ColumnName); if (dt.Rows[iRow][iCol] != DBNull.Value) { if (dt.Rows[iRow][iCol] is Guid) { wr.WriteValue(((Guid)dt.Rows[iRow][iCol]).ToString()); } else { wr.WriteValue(dt.Rows[iRow][iCol]); } } wr.WriteEndElement(); } wr.WriteEndElement(); } wr.WriteEndElement(); wr.Flush(); } return(sb.ToString()); }
// // .ctor // public System.Xml.XPath.XPathNavigator TransformData(System.Xml.XPath.XPathNavigator nav, int cacheduration, IPDFDataSource source, PDFDataContext context) { //Check we have something to use for a transformation. if (string.IsNullOrEmpty(this.XSLTPath) && null == this.Transformer) { return(nav); } System.Xml.XmlWriter xmlWriter = null; System.IO.MemoryStream memoryStream = null; System.IO.StreamWriter streamWriter = null; System.Xml.XmlDocument result = null; System.Xml.XmlDocument output = new System.Xml.XmlDocument(); try { System.Xml.Xsl.XslCompiledTransform trans = this.DoGetTransformer(cacheduration, source, context); System.Xml.Xsl.XsltArgumentList args = this.DoGetArguments(context); memoryStream = new System.IO.MemoryStream(); streamWriter = new System.IO.StreamWriter(memoryStream, Encoding.UTF8); System.Xml.XmlWriterSettings writerSettings = CreateWriterSettings(); xmlWriter = System.Xml.XmlWriter.Create(streamWriter, writerSettings); trans.Transform(nav, args, xmlWriter); xmlWriter.Flush(); streamWriter.Flush(); result = new System.Xml.XmlDocument(); memoryStream.Position = 0; result.Load(memoryStream); } catch (Exception ex) { throw new PDFDataException(Errors.CouldNotTransformInputData, ex); } finally { if (null != xmlWriter) { xmlWriter.Close(); } if (null != streamWriter) { streamWriter.Dispose(); } if (null != memoryStream) { memoryStream.Dispose(); } } return(result.CreateNavigator()); }
private void Serialize <T>(T obj, string sConfigFilePath) { System.Xml.Serialization.XmlSerializer XmlBuddy = new System.Xml.Serialization.XmlSerializer(typeof(T)); System.Xml.XmlWriterSettings MySettings = new System.Xml.XmlWriterSettings(); MySettings.Indent = true; MySettings.CloseOutput = true; MySettings.OmitXmlDeclaration = true; System.Xml.XmlWriter MyWriter = System.Xml.XmlWriter.Create(sConfigFilePath, MySettings); XmlBuddy.Serialize(MyWriter, obj); MyWriter.Flush(); MyWriter.Close(); }
private void Click_Export(object sender, RoutedEventArgs e) { if (tbxPath.Text.Length == 0) { MessageBox.Show("Выберите папку для сохраения файла!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (rbXLS.IsChecked == true) { string connectionString = "Provider = Microsoft.Jet.OLEDB.4.0;Extended properties = Excel 8.0; Data Source = " + tbxPath.Text + @"\Export.xls"; OleDbConnection conn = new OleDbConnection(connectionString); conn.Open(); OleDbCommand cmd = new OleDbCommand(); cmd.Connection = conn; cmd.CommandText = "Create Table [Sponsorships] (Name Varchar, Championship Varchar, Skill Varchar, SponsorClassName Varchar, Sponsor Varchar, Amount Varchar, Picture Varchar)"; cmd.ExecuteNonQuery(); foreach (var i in cs.StaticClass.SponsorshipList) { cmd.CommandText = "Insert Into [Sponsorships] (Name , Championship , Skill , SponsorClassName , Sponsor , Amount , Picture) Values ('" + i.Name + "', '" + i.Championship.Name + "', '" + i.Competition.NameRussian + "', '" + i.SponsorClassName + "', '" + i.Sponsor + "', '" + i.Amount + "', '" + i.Picture + "')"; cmd.ExecuteNonQuery(); } conn.Close(); } else if (rbXML.IsChecked == true) { System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(tbxPath.Text + @"\Export.xml"); writer.WriteStartDocument(); writer.WriteStartElement("Sponsorships"); foreach (var i in cs.StaticClass.SponsorshipList) { writer.WriteStartElement("Sponsorship"); writer.WriteElementString("Name", i.Name); writer.WriteElementString("Championship", i.Championship.Name); writer.WriteElementString("Skill", i.Competition.NameRussian); writer.WriteElementString("SponsorClassName", i.SponsorClassName); writer.WriteElementString("Sponsor", i.Sponsor); writer.WriteElementString("Amount", i.Amount + ""); writer.WriteElementString("Picture", i.Picture + ""); writer.WriteEndElement(); writer.Flush(); } writer.WriteEndElement(); writer.WriteEndDocument(); writer.Close(); } MessageBox.Show("Экспорт совершён!", "Perfect", MessageBoxButton.OK, MessageBoxImage.Information); }
public static void SaveEntityToFile <TEntity>(this TEntity entity, string folder, string fileName) where TEntity : Models.BaseClasses.GStoreEntity, new() { if (!System.IO.Directory.Exists(folder)) { System.IO.Directory.CreateDirectory(folder); System.Diagnostics.Trace.WriteLine("--SaveEntityToFile File System: Created folder: " + folder); } System.Xml.XmlWriterSettings xmlSettings = new System.Xml.XmlWriterSettings() { Async = false, CloseOutput = true, Encoding = System.Text.Encoding.UTF8, Indent = true, IndentChars = "\t", NewLineHandling = System.Xml.NewLineHandling.None, WriteEndDocumentOnClose = true }; System.Xml.XmlWriter xmlWriter = System.Xml.XmlWriter.Create(folder + "\\" + fileName, xmlSettings); System.Xml.Serialization.XmlSerializer xmlSerializer = null; try { TEntity poco = null; if (entity.IsPoco()) { poco = entity; } else { poco = entity.GetPoco(); } xmlSerializer = new System.Xml.Serialization.XmlSerializer(poco.GetType()); xmlSerializer.Serialize(xmlWriter, poco); System.Diagnostics.Trace.WriteLine("--SaveEntityToFile: Wrote entity type " + entity.GetType().FullName + " to Folder: " + folder + " FileName: " + fileName); } catch (Exception ex) { string message = "Error in SaveEntityToFile: Error saving entity type " + entity.GetType().FullName + " to Folder: " + folder + " FileName: " + fileName + " Exception: " + ex.ToString(); System.Diagnostics.Trace.WriteLine("--" + message); throw new ApplicationException(message, ex); } finally { xmlWriter.Flush(); xmlWriter.Close(); } }
public static System.Xml.XmlDocument SerializeToXMLDocument <T>(this object obj) { XmlSerializer serializer = new XmlSerializer(obj.GetType()); //TextWriter textWriter = new StreamWriter(@"C:\movie.xml"); StringBuilder sb = new StringBuilder(); System.Xml.XmlWriter xmlwriter = System.Xml.XmlWriter.Create(sb); serializer.Serialize(xmlwriter, obj); xmlwriter.Close(); xmlwriter.Flush(); System.Xml.XmlDocument xml = new System.Xml.XmlDocument(); xml.LoadXml(sb.ToString()); return(xml); }
/// <summary> /// 将DataSet 转换成带架构的xml /// </summary> /// <param name="ds"></param> /// <returns></returns> public static string GetXmlAndSchema(this DataSet ds) { try { StringBuilder xmlDataStr = new StringBuilder(); System.Xml.XmlWriter witer = System.Xml.XmlWriter.Create(xmlDataStr); ds.WriteXml(witer, XmlWriteMode.WriteSchema); witer.Flush(); witer.Close(); return(xmlDataStr.ToString()); } catch (Exception ex) { throw ex; } }
public void SaveDependencies() { if (writer == null) { return; } writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); writer.Dispose(); zipStream.Dispose(); writer = null; zipStream = null; dependency_stack = null; }
public void BeforeSendReply(ref Message reply, object correlationState) { XmlConfigurator.Configure(new System.IO.FileInfo(Path.Combine(AssemblyDirectory, "log4netConfig.config"))); MessageBuffer buffer = reply.CreateBufferedCopy(Int32.MaxValue); Message copyReply = buffer.CreateMessage(); StringBuilder sb = new StringBuilder(); using (System.Xml.XmlWriter xw = System.Xml.XmlWriter.Create(sb)) { copyReply.WriteMessage(xw); xw.Flush(); xw.Close(); } log.Info(sb.ToString()); reply = buffer.CreateMessage(); }
public object AfterReceiveRequest(ref Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext) { XmlConfigurator.Configure(new System.IO.FileInfo(Path.Combine(AssemblyDirectory, "log4netConfig.config"))); MessageBuffer buffer = request.CreateBufferedCopy(Int32.MaxValue); Message copyRequest = buffer.CreateMessage(); StringBuilder sb = new StringBuilder(); using (System.Xml.XmlWriter xw = System.Xml.XmlWriter.Create(sb)) { copyRequest.WriteMessage(xw); xw.Flush(); xw.Close(); } log.Info(sb.ToString()); request = buffer.CreateMessage(); return(null); }
public static void _ListQueuesCallback(Object obj, out SqlString name, out SqlString url, out SqlXml metadata) { if (!(obj is ITPCfSQL.Azure.Queue)) { throw new ArgumentException("Expected " + typeof(ITPCfSQL.Azure.Queue).ToString() + ", received " + obj.GetType().ToString()); } ITPCfSQL.Azure.Queue q = (ITPCfSQL.Azure.Queue)obj; name = q.Name; url = q.Url.ToString(); if ((q.Metadata != null) && (q.Metadata.Count > 0)) { System.IO.MemoryStream ms = new System.IO.MemoryStream(); using (System.Xml.XmlWriter wr = System.Xml.XmlWriter.Create(ms)) { wr.WriteStartElement("MetadataList"); foreach (string s in q.Metadata.Keys) { wr.WriteStartElement(s); wr.WriteString(q.Metadata[s]); wr.WriteEndElement(); } wr.WriteEndElement(); wr.Flush(); wr.Close(); } ms.Seek(0, System.IO.SeekOrigin.Begin); metadata = new SqlXml(ms); } else { metadata = null; } }
private void Serialize <T>(T obj, string sConfigFilePath) { try { System.Xml.Serialization.XmlSerializer XmlBuddy = new System.Xml.Serialization.XmlSerializer(typeof(T)); System.Xml.XmlWriterSettings MySettings = new System.Xml.XmlWriterSettings(); MySettings.Indent = true; MySettings.CloseOutput = true; MySettings.OmitXmlDeclaration = true; System.Xml.XmlWriter MyWriter = System.Xml.XmlWriter.Create(sConfigFilePath, MySettings); XmlBuddy.Serialize(MyWriter, obj); MyWriter.Flush(); MyWriter.Close(); } catch (Exception ex) { account.Log(new ErrorTextInformation(ex.Message + ex.StackTrace), 0); } }
/// <summary> /// Formats the provided XML so it's indented and humanly-readable. /// </summary> /// <param name="inputXml">The input XML to format.</param> /// <returns></returns> public static string FormatXml(string xml, bool omitXmlDeclaration, string indentChars) { // XmlDocument.LoadXml sadece tam ve net sentaxlý xml ler için // string den oluþan ve xml gibi görünen tüm genel xml ler için aþaðýdaki gibi kullanmak gerekiyormuþ // çünkü stringler UTF-16 ile çalýþýrlarmýþ, sorun çýkmamasý için aþaðýdaki gibi yapýyoruz. // http://stackoverflow.com/questions/310669/why-does-c-xmldocument-loadxmlstring-fail-when-an-xml-header-is-included // Aþaðýdaki implementasyon bu soruna çözüm oluyor byte[] encodedString = System.Text.Encoding.UTF8.GetBytes(xml); System.Xml.XmlDocument document = new System.Xml.XmlDocument(); // Put the byte array into a stream and rewind it to the beginning using (MemoryStream ms = new MemoryStream(encodedString)) { ms.Flush(); ms.Position = 0; document.Load(ms); } System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings(); settings.Indent = true; if (indentChars != null) { settings.IndentChars = indentChars; // settings.IndentChars = "\t"; } settings.OmitXmlDeclaration = omitXmlDeclaration; // üst xml deklarasyonu kaldýrýr //settings.NewLineOnAttributes = false; //settings.Encoding = encoding; System.Text.StringBuilder output = new System.Text.StringBuilder(); using (System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(output, settings)) { document.WriteContentTo(writer); writer.Flush(); } return(output.ToString()); }
public override void Generate ( System.Xml.XmlWriter xmlWriter ) { this._WrittenRootNode = false; xmlWriter.WriteStartDocument(true); if (this.RootElement is ICatalog) { this.Write(xmlWriter, this.RootElement as XCRI.Interfaces.XCRICAP11.ICatalog); } if (this.RootElement is IProvider) { this.Write(xmlWriter, this.RootElement as XCRI.Interfaces.XCRICAP11.IProvider); } if (this.RootElement is ICourse) { this.Write(xmlWriter, this.RootElement as XCRI.Interfaces.XCRICAP11.ICourse); } xmlWriter.Flush(); }
private System.IO.Stream MessageToStream(Message message, HttpContextServiceHost ctx) { System.IO.Stream ms = new System.IO.MemoryStream(); using (System.IO.Stream tempms = new System.IO.MemoryStream()) { using (System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(tempms)) { message.WriteMessage(writer); writer.Flush(); } ctx.OriginalContentLength = (int)tempms.Length; tempms.Position = 0; /* * using (System.IO.FileStream fs = new FileStream(@"d:\f1.xml", FileMode.CreateNew)) * { * tempms.CopyTo(fs); * fs.Flush(); * } * tempms.Position = 0; */ using (System.IO.Compression.GZipStream gzip = new System.IO.Compression.GZipStream(ms, System.IO.Compression.CompressionMode.Compress, true)) { tempms.CopyTo(gzip); } } ms.Position = 0; /* * using (System.IO.FileStream fs = new FileStream(@"d:\f2.xml.zip", FileMode.CreateNew)) * { * ms.CopyTo(fs); * fs.Flush(); * } * ms.Position = 0; */ return(ms); }
public static async Task WriteXmlFile(Windows.Storage.StorageFile file, Person person) { try { using (IRandomAccessStream writeStream = await file.OpenAsync(FileAccessMode.ReadWrite)) { System.IO.Stream s = writeStream.AsStreamForWrite(); System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings(); settings.Async = true; using (System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(s, settings)) { writer.WriteStartElement("Person"); writer.WriteElementString("Name", person.Name); writer.WriteElementString("Age", Convert.ToString(person.Age)); writer.WriteElementString("City", person.City); writer.Flush(); await writer.FlushAsync(); } } } catch { } }
void IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { // This is the chunking code. // ASP.NET buffering must be turned off for this to work. int bufferSize = 4096; char[] songBytes = new char[bufferSize]; FileStream inFile = File.Open(this.filePath, FileMode.Open, FileAccess.Read); long length = inFile.Length; // Write the file name. writer.WriteElementString("fileName", ns, Path.GetFileNameWithoutExtension(this.filePath)); // Write the size. writer.WriteElementString("size", ns, length.ToString()); // Write the song bytes. writer.WriteStartElement("song", ns); StreamReader sr = new StreamReader(inFile, true); int readLen = sr.Read(songBytes, 0, bufferSize); while (readLen > 0) { writer.WriteStartElement("chunk", ns); writer.WriteChars(songBytes, 0, readLen); writer.WriteEndElement(); writer.Flush(); readLen = sr.Read(songBytes, 0, bufferSize); } writer.WriteEndElement(); inFile.Close(); }
public void WriteXML(System.Xml.XmlWriter x, System.Data.DataTable datatable) { this.Table.DataTable = datatable; // --------------- x.WriteStartDocument(); x.WriteStartFlowDocument(); x.WriteTextStyleAttributes(this.TextStyle); x.WriteX(this.ReportHeaderDefinition.ReportTitle); x.WriteX(this.ReportHeaderDefinition.HeaderText); x.WriteX(this.Table); x.WriteX(this.ReportFooterDefinition.FooterText); x.WriteEndFlowDocument(); x.WriteEndDocument(); x.Flush(); }
public void WriteXml(System.Xml.XmlWriter writer) { writer.WriteStartElement("xsi","Thing", @"http://www.w3.org/2001/XMLSchema-instance"); foreach (Widget widget in Widgets) { if (string.IsNullOrEmpty(widget.Value)) { writer.WriteStartElement("widget"); writer.WriteAttributeString("Name", widget.Name); writer.WriteAttributeString("xsi", "nil", @"http://www.w3.org/2001/XMLSchema-instance", "true"); writer.WriteEndElement(); } else { writer.WriteStartElement("widget"); writer.WriteAttributeString("Name", widget.Name); writer.WriteString(widget.Value); writer.WriteEndElement(); } } writer.WriteEndElement(); writer.Flush(); }