C# .NET - Loading two XML files from one dataset based on a parameter

Asked By samaira samaira
03-Feb-12 07:53 AM
how do I Load two XML files from one dataset based on a  dataset parameter in different paths
  Peter Bromberg replied to samaira samaira
03-Feb-12 08:03 AM
Your question is unclear. A dataset can only generate or read one XML Document.
  samaira samaira replied to Peter Bromberg
03-Feb-12 08:17 AM
datarow dtr;i
f((string)dtr["SourceSystem"]=="Client")
{
using (XmlTextWriter writer = new XmlTextWriter(@"C:\ModeIntegration\Inputs\Output_client.xml", null)
{
//code
}}
else if(if((string)dtr["SourceSystem"]=="Source"))
using (XmlTextWriter writer = new XmlTextWriter(@"C:\ModeIntegration\Inputs\Output_source.xml", null)
{
//code
}
  Riley K replied to samaira samaira
03-Feb-12 08:47 AM


Try something with merge

refer this link

http://stackoverflow.com/questions/6583414/import-multiple-xml-files-into-a-dataset 

Regards
  Peter Bromberg replied to samaira samaira
03-Feb-12 08:47 AM
Where you have your //code comments, the DataSet has  ReadXml method that you can use.
  kalpana aparnathi replied to samaira samaira
03-Feb-12 01:07 PM
One solution I can think of would be read each XML file into its own DataSet, then add each individual DataSet's tables to a "main" DataSet, then report that main DataSet.
Create New Account
help
to convert passed dataset to XML data public string ConvertDataSetToXML(DataSet xmlDS) { MemoryStream stream = null ; XmlTextWriter writer = null ; try { stream = new MemoryStream(); / / Load the XmlTextReader from the stream writer = new XmlTextWriter(stream, Encoding.Unicode); / / Write to the file with the WriteXml method. xmlDS.WriteXml(writer); int Close(); } } Now let look at saving this XML TO DataBase. . . DataSet reportData = new DataSet(); reportData.ReadXml(Server.MapPath(”report.xml”)); SqlConnection connection = new SqlConnection(”CONNECTION STRING”); SqlBulkCopy sbc = new SqlBulkCopy(connection); sbc.DestinationTableName = “report_table
0in 5.4pt 0in 5.4pt'> style = 'text-align:center'> select = "format-number(sum(NewDataSet / Report / kbytes) div 1024, '###, ###, ##0.###')" / > white 2.25pt;background: #F2F2F2;padding:0in 5.4pt 0in 5.4pt'> style = 'text-align:center'> select = "format-number(sum(NewDataSet / Report / count), '###, ###, ##0')" / > 5.4pt 0in 5.4pt'> style = 'text-align:center'> select = "format-number(sum NewDataSet / Report / pages), '###, ###, ##0.#')" / > basis is shown below:< / p> cellpadding = "0" style = 'border-collapse:collapse;mso-yfti 5.4pt'> style = 'text-align:center;mso-yfti-cnfc:64'> select = "format-number(sum(NewDataSet / Report / kbytes) div 1024, '###, ###, ##0.###')" / > white 2.25pt;mso-border-top-alt: solid white 2.25pt 5.4pt'> style = 'text-align:center;mso-yfti-cnfc:64'> select = "format-number(sum(NewDataSet / Report / count), '###, ###, ##0')" / > style = 'border:none;mso-border-top-alt:solid white 2.25pt; mso-border 5.4pt'> style = 'text-align:center;mso-yfti-cnfc:64'> select = "format-number(sum(NewDataSet / Report / pages), '###, ###, ##0.#')" / > Here is the C# code: private void RenderReport(string reportXml, string sXsltFile, string sOutfile, int nOption ) { / / Option 1 = detailed, 2 = summary DisplayStatusMsg(0, "Processing"); DisplayStatusMsg(1, "Creating detailed report " + sOutfile); Application.DoEvents(); try { / / read data for this report StreamReader reader = new StreamReader(reportXml); / / preps xml to be transformed XPathDocument document = new XPathDocument(reader
_schema.Id = _tableName; } } System.Xml.Schema.XmlSchema IXmlSerializable.GetSchema() { throw new System.NotImplementedException(); } void IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { base.ReadXml(reader); } void IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { base.WriteXml(writer, XmlWriteMode.DiffGram); } private void GetTableSchema() { System.IO.MemoryStream stream = new System.IO.MemoryStream(); this.WriteXmlSchema(new System.Xml.XmlTextWriter(stream, null)); stream.Position = 0; _schema = XmlSchema.Read(new System.Xml.XmlTextReader(stream), null); } public _schema.Id = _tableName; } } System.Xml.Schema.XmlSchema IXmlSerializable.GetSchema() { throw new System.NotImplementedException(); } void IXmlSerializable.ReadXml(System.Xml.XmlReader reader) { base.ReadXml(reader); } void IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) { base.WriteXml(writer, XmlWriteMode.DiffGram); } private void GetTableSchema() { System.IO.MemoryStream stream = new System.IO.MemoryStream(); this.WriteXmlSchema(new System.Xml.XmlTextWriter(stream, null)); stream.Position = 0; _schema = XmlSchema.Read(new System.Xml.XmlTextReader(stream), null); } public Schema.XmlSchema IXmlSerializable.GetSchema() \ par \ { \ par throw new System.NotImplementedException(); \ par \ } \ par \ par void IXmlSerializable.ReadXml(System.Xml.XmlReader reader) \ par \ { \ par base.ReadXml(reader); \ par \ } \ par \ par void IXmlSerializable.WriteXml(System.Xml.XmlWriter writer) \ par \ { \ par base.WriteXml
and it changed: Downloading is paused 2010-05-07 14:02:51:170 1300 120c Report REPORT EVENT: {C0E87EF8-ADAD-4562-8CB7-D6C40275CD73} 2010-05-07 13:58:24:299+0200 1 Security Update for Windows Vista (KB979683) 2010-05-07 14:02:51:170 1300 120c Report REPORT EVENT: {E462F050-007B-4A40-B929-6C254F58DB9B} 2010-05-07 13:58:24:704+0200 1 Security Update for Windows Vista (KB981332). 2010-05-07 14:02:51:171 1300 120c Report REPORT EVENT: {C18E1DC7-BD50-4E02-A55D-B00A88F87A19} 2010-05-07 13:58:25:074+0200 1 E-mail Filter [March 2010] (KB905866) 2010-05-07 14:02:51:171 1300 120c Report REPORT EVENT: {F948ADBA-03D9-4F25-B449-365319AC6E23} 2010-05-07 13:58:25:429+0200 1