I have a xml schema that based on that I have generated the schema class.
I am using xmlserializer and I have tried to add
nillable="true"
so that it shows me the elements that are not null.
What I have tried:
it shows me the result like this:
<Info>
<Fl>
<Name>Test</Name>
<News d3p1:nil="true" xmlns:d3p1="http://www.w3.org/2001/XMLSchema-instance"/>
</Fl>
</Info>
but I want the result like this:
<Info>
<Fl>
<Name>Test</Name>
<News/>
</Fl>
</Info>
This is my C# code :
Info resp = new Info();
resp.Fl = data;
var serializer = new XmlSerializer(typeof(Info));
using (var stream = new StreamWriter("E:\\report.xml"))
{
XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces();
namespaces.Add(string.Empty, string.Empty);
serializer.Serialize(stream, resp, namespaces);
bRet = true;
}
and this my xsd :
<xs:schema id="Response" xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified">
<xs:element name="Info">
<xs:complexType>
<xs:sequence>
<xs:element name="Fl" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="Name" nillable="true"/>
<xs:element type="xs:string" name="News" nillable="true"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
How can I have the result I am expecting?