Hi,
I need to load xml report to XmlDocument, modify and load this xml as a report. I'm loading xml file to XmlDocument and then saving it to memory stream. Then I'm loading report from memory stream. The problem is that report look different. There are some problems with page header and footer. Loading report directly from file works fine. In my opinion the problem is with XmlDocument. Maybe some encoding problems ? Any ideas ?
regards
I've solved problem in different way. I had to use LoadOptions.PreserveWhiteSpaces
regards,
Sebastian
Thanks Petar. That's what I intended to paste, but your forum software seems to have some issues. Almost every thread I look at has someone trying to paste some code, and it always looks terrible. Is someone ever going to fix that?
Thanks, Mike
Hello Mike,
I have been following through this thread and was wondering if this is the code you intended of pasting:
“ XElement document = XElement.Parse( template, LoadOptions.PreserveWhitespace );
XNamespace igr = document.GetDefaultNamespace();
XElement pageSettings = document.Descendants(igr + "PageSettings").FirstOrDefault();
Once I have finished with the document, I use the following code to finally generate the report.
string report = document.ToString();
using (IServerExporter exporter = ServerExporterFactory.CreateExporter(new MemoryStream(Encoding.UTF8.GetBytes(report))))
{
using (MemoryStream memoryStream = new MemoryStream())
exporter.DataSources = dataSourceValues;
exporter.Export(memoryStream, GetExportFormat(exportParameters.ExportFormat));
using (FileStream outStream = File.OpenWrite(filePath))
memoryStream.WriteTo(outStream);
}
} ”
Please let me know if I can be of any further assistance.
There's a bunch of duplication in that post, and I can't seem to edit it. Sorry about the mess.
Mike
As I said, I'm not using XmlDocument, I'm using the newer XElement class hierarchy. I load the report defintion from a file system into a string (template, below). Then I use code like the following to load and examine it:
.PreserveWhitespace );
igr = document.GetDefaultNamespace();
).FirstOrDefault();
using
( IServerExporter exporter = ServerExporterFactory.CreateExporter(
new
MemoryStream( Encoding.UTF8.GetBytes( report )
) )
using ( FileStream outStream = File.OpenWrite( filePath ) )
memoryStream.WriteTo( outStream );
exporter.Export( memoryStream, GetExportFormat( exportParameters.ExportFormat ) );
using ( MemoryStream memoryStream = new MemoryStream() )
Sorry about the formatting, but it's the forum software that wrecks it. The above code is somewhat simplified from what I'm actually doing (for clarity) but I hope it helps you.