Advertisement

02.26.2008 at 11:17AM PST, ID: 23194642
[x]
Attachment Details

XML Serialize object with DataTable

Asked by ARACK04 in C# Programming Language, Extensible Markup Language (XML), Microsoft Visual Basic.Net

Tags: C#, VB.NET, XML

I'm trying to serialize a *List* of objects, where each object contains a DataTable.  I'm just using the XmlSerializer, out of the box.  The result I'm getting is that each object (in the resulting XML) is defining a custom type for the DataTable, as listed at the bottom.  My question is, how can I get the generated XML to define this complex type *once*, and use it for every object in my result?

Oh, and I'm using C#, but examples in VB would be just fine.

Thanks!

                <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
                  <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="PropertiesA" msdata:UseCurrentLocale="true">
                    <xs:complexType>
                      <xs:choice minOccurs="0" maxOccurs="unbounded">
                        <xs:element name="PropertiesA">
                          <xs:complexType>
                            <xs:sequence>
                              <xs:element name="Value" type="xs:string" minOccurs="0" />
                              <xs:element name="ColumnName" type="xs:string" minOccurs="0" />
                              <xs:element name="DataType" type="xs:string" minOccurs="0" />
                              <xs:element name="FrameworkDataType" type="xs:string" minOccurs="0" />
                              <xs:element name="IsIdentity" type="xs:boolean" minOccurs="0" />
                              <xs:element name="DbDataType" type="xs:string" minOccurs="0" />
                            </xs:sequence>
                          </xs:complexType>
                        </xs:element>
                      </xs:choice>
                    </xs:complexType>
                  </xs:element>
                </xs:schema>

Start Free Trial
[+][-]02.26.2008 at 11:31AM PST, ID: 20987792

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.26.2008 at 11:39AM PST, ID: 20987875

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.26.2008 at 11:41AM PST, ID: 20987903

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.26.2008 at 11:42AM PST, ID: 20987921

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: C# Programming Language, Extensible Markup Language (XML), Microsoft Visual Basic.Net
Tags: C#, VB.NET, XML
Sign Up Now!
Solution Provided By: ShazbotOK
Participating Experts: 2
Solution Grade: A
 
 
[+][-]02.26.2008 at 12:13PM PST, ID: 20988282

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.26.2008 at 12:33PM PST, ID: 20988460

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628