Sure, Here's a hacked up test case that recreates it
The serialization code
public Form1()
{
testClass test = new testClass();
InitializeComponent();
try
{
XmlSerializer x = new XmlSerializer(typeof(testClass));
TextWriter writer = new StreamWriter("\\Program Files\\log scale manager
2\\" + "HBS.xml");
x.Serialize(writer, test);
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
}
The testClass code
namespace XML_test1{
using System.Xml.Serialization;
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Xml;
using System.Xml.Schema;
using System.IO;
[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d", "2.0.50727.42")]
// [System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Xml.Serialization.XmlTypeAttribute(Anonymou sType=true)]
public partial class testClass {
private string eventTypeField;
private string pSCommonField;
private string loadArrivalNumberField;
[System.Xml.Serialization.XmlElementAttribute(Order = 0)]
public string EventType
{
get
{ return this.eventTypeField; }
set
{ this.eventTypeField = value; }
}
[System.Xml.Serialization.XmlElementAttribute(Order = 1)]
public string PSCommon
{
get
{ return this.pSCommonField; }
set
{ this.pSCommonField = value; }
}
[System.Xml.Serialization.XmlElementAttribute(Order = 2)]
public string LoadArrivalNumber
{
get
{ return this.loadArrivalNumberField; }
set
{ this.loadArrivalNumberField = value; }
}
public testClass()
{
EventType = "1";
PSCommon = "";
LoadArrivalNumber = "3";
}
}
}
This results in
<?xml version="1.0" encoding="utf-8"?>
<testClass xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<EventType>1</EventType>
<PSCommon/>
<LoadArrivalNumber>3</LoadArrivalNumber>
</testClass>
I found that by checking if PSCommon.Trim() == "" and then setting it to
null if true prevents
<PSCommon/> from appearing.
Annoying hack but it works.
"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:88**************@TK2MSFTNGXA01.phx.gbl...
Hi Jamie,
Could you post some code of your class and the serialization code, so that
we can try to make a repro on this issue?
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."