The code that I have merges one xml file into another but it appends the xml to the end of the file, I need to insert the tag set in one file into another file in a particular location.
Here is my code:
protected void AddFilter(string ReportFile, string mdsName)
{
string FilterText = String.Empty;
string txt;
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(ReportFile);
try
{
if (FilterTxt.Value.ToString() !="")
{
FilterText = HttpUtility.UrlDecode(FilterTxt.Value.ToString());
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
TextWriter tw = new StreamWriter("D:\\FilterTest.rdl");
tw.WriteLine(FilterText);
tw.Close();
XmlDocument doc = new XmlDocument();
XmlNode cont = doc.CreateElement("Filters");
doc.AppendChild(cont);
doc.
// first document to merge (the ReportFile)
XmlDocument reportrdl = new XmlDocument();
reportrdl.Load(ReportFile);
XmlNode imported = doc.ImportNode(reportrdl.DocumentElement, true);
doc.DocumentElement.AppendChild(imported);
String query = "DataSet[@Name="+mdsName+"]";
XmlNodeList mydataset = doc.SelectNodes(query);
foreach (XmlElement dst in mydataset)
{
// second document to merge (the new Filter File)
XmlDocument filterrdl = new XmlDocument();
filterrdl.Load("D:\\FilterTest.rdl");
imported = doc.ImportNode(filterrdl.DocumentElement, true);
doc.DocumentElement.AppendChild(imported);
}
// print merged documents
doc.Save("D:\\NewFilter.rdl");
}
}
finally
{
//fileStream.Close();
}
The attempt to use SelectNodes fails and it never drops into the foreach.
I need help kinda fast...
Thanks in advance
Dean
}//end AddFilter module
Here is my code:
protected void AddFilter(string ReportFile, string mdsName)
{
string FilterText = String.Empty;
string txt;
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(ReportFile);
try
{
if (FilterTxt.Value.ToString() !="")
{
FilterText = HttpUtility.UrlDecode(FilterTxt.Value.ToString());
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
TextWriter tw = new StreamWriter("D:\\FilterTest.rdl");
tw.WriteLine(FilterText);
tw.Close();
XmlDocument doc = new XmlDocument();
XmlNode cont = doc.CreateElement("Filters");
doc.AppendChild(cont);
doc.
// first document to merge (the ReportFile)
XmlDocument reportrdl = new XmlDocument();
reportrdl.Load(ReportFile);
XmlNode imported = doc.ImportNode(reportrdl.DocumentElement, true);
doc.DocumentElement.AppendChild(imported);
String query = "DataSet[@Name="+mdsName+"]";
XmlNodeList mydataset = doc.SelectNodes(query);
foreach (XmlElement dst in mydataset)
{
// second document to merge (the new Filter File)
XmlDocument filterrdl = new XmlDocument();
filterrdl.Load("D:\\FilterTest.rdl");
imported = doc.ImportNode(filterrdl.DocumentElement, true);
doc.DocumentElement.AppendChild(imported);
}
// print merged documents
doc.Save("D:\\NewFilter.rdl");
}
}
finally
{
//fileStream.Close();
}
The attempt to use SelectNodes fails and it never drops into the foreach.
I need help kinda fast...
Thanks in advance
Dean
}//end AddFilter module