开发者

XML Serializer skipping over rows

I have an application that reads records from the database and exports it out to an xml file. There is a xsd in place that draws out the schema of the xml file. I am using the xsd proxy classes to then serialize the data to xml file.

This is how I am serializing the data to xml:

XmlSerializer serializer = new XmlSerializer(_report.GetType());
StringBuilder xmlString = new StringBuilder();
StringWriter writer = new StringWriter(xmlString);
serializer.Serialize(writer, _report);
XmlDocument doc = new XmlDocument();
doc.LoadXml(xmlString.ToString());
doc.Save(_outputFile.FullName);

The problem I am having is that in the output file there are missing rows. I went through the debug and found out that the data is being added to the collection of the proxy objects from the database and getting passed to the serializer via the '_report' object.

So to isolated the issue of data or app, I hand coded a few of the missing records into a csv file and imported the data into my app. Those records were now appearing in the xml file. So, now I know that this is a data issue. The app is using informix database as the backend.

What I don't understand is that why some of the rows from the same table in the informix database be present and other not? I have spent almost 2-3 days on this looking around on the INTERNET without any success. So, I figured its time to t开发者_开发知识库urn it up a notch.


I had a similar problem 2 day ago.

try adding

 writer.Flush();

before you call

 xmlString.ToString());

That was the solution that solved my problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜