Advertisement

05.28.2008 at 01:10PM PDT, ID: 23439448
[x]
Attachment Details

WriteXML gives strange output

Asked by rwallacej in Extensible Markup Language (XML), Programming for ASP.NET, ADO.Net Class Library

Tags: asp.net

Hi
Perhaps someone can help.

I've got an XSD, produced in Visual Studio, called ProductionDataSet.xsd with one DataTable named "ProductionData"

"ProductionData" has numeric fields; say they are called FieldA, FieldB, FieldC
Nothing fancy for this trial or any restrictions.

I used the xsd.exe to create strongly typed .VB class, called "ProductionDataSet.vb"
So now the dataset and schema is setup correctly I think.

In the code I create a dummy set of data and try exporting it to an XML file using the WriteXML.

If I have
        Dim ds2 As New DataSet
        ds2.ReadXmlSchema(filename)                     'filename is ProductionDataSet.xsd
         'add data here..
        ds2.Tables(0).Rows.Add("1", "2", "3")
        ds2.Tables(0).Rows.Add("4", "6", "10")
        ds2.Tables(0).Rows.Add("5", "8", "12")
       'output to XML file
        myXmlDataDocument.DataSet.WriteXml("c:\output1.xml")

the output works fine for above:

<?xml version="1.0" standalone="yes"?>
<ProductionDataSet xmlns="http://tempuri.org/ProductionDataSet.xsd">
  <ProductionData>
    <FieldA>1</FieldA>
    <FieldB>2</FieldB>
    <FieldC>3</FieldC>
  </ProductionData>
  <ProductionData>
    <FieldA>4</FieldA>
    <FieldB>6</FieldB>
    <FieldC>10</FieldC>
  </ProductionData>
  <ProductionData>
    <FieldA>5</FieldA>
    <FieldB>8</FieldB>
    <FieldC>12</FieldC>
  </ProductionData>
</ProductionDataSet>

HOWEVER this uses an array of parameters, not strongly typed......so I thought I could use

Dim production As New ProductionDataSetProductionData()
        production.FieldA = 123
        production.FieldB = 456
        ds2.Tables(0).Rows.Add(production)

The output it produces appends to the above and is a problem. Instead of appending
<ProductionData>
    <FieldA>123</FieldA>
    <FieldB>456</FieldB>
  </ProductionData>

I get......
  <ProductionData>
    <FieldA>ProductionDataSetProductionData</FieldA>
  </ProductionData>

What is going up here?  Obviously     <FieldA>ProductionDataSetProductionData</FieldA>  isn't what  I want.

Thanks in advance for help - this is really troubling me Start Free Trial
 
 
[+][-]05.28.2008 at 02:08PM PDT, ID: 21664407

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.

 
[+][-]05.28.2008 at 02:32PM PDT, ID: 21664556

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.

 
[+][-]05.28.2008 at 02:37PM PDT, ID: 21664588

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.

 
[+][-]05.28.2008 at 07:25PM PDT, ID: 21665886

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.

 
[+][-]05.29.2008 at 02:16AM PDT, ID: 21667432

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.

 
[+][-]05.29.2008 at 02:19AM PDT, ID: 21667446

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.

 
[+][-]05.29.2008 at 02:23AM PDT, ID: 21667464

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.

 
[+][-]05.29.2008 at 05:50AM PDT, ID: 21668523

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.

 
[+][-]05.29.2008 at 07:16AM PDT, ID: 21669296

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.

 
[+][-]05.29.2008 at 07:26AM PDT, ID: 21669380

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.

 
[+][-]05.29.2008 at 08:28AM PDT, ID: 21670036

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.

 
[+][-]05.29.2008 at 08:29AM PDT, ID: 21670043

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.

 
[+][-]05.29.2008 at 08:29AM PDT, ID: 21670048

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.

 
[+][-]05.29.2008 at 08:34AM PDT, ID: 21670095

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.

 
[+][-]05.29.2008 at 03:07PM PDT, ID: 21673741

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.

 
[+][-]05.29.2008 at 03:17PM PDT, ID: 21673807

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.

 
[+][-]05.30.2008 at 06:39AM PDT, ID: 21677587

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.

 
[+][-]05.30.2008 at 07:36AM PDT, ID: 21678137

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.

 
[+][-]05.30.2008 at 07:43AM PDT, ID: 21678208

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.

 
[+][-]05.30.2008 at 07:59AM PDT, ID: 21678380

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.

 
[+][-]05.30.2008 at 08:00AM PDT, ID: 21678387

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.

 
[+][-]05.30.2008 at 08:09AM PDT, ID: 21678488

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.

 
[+][-]05.30.2008 at 09:16AM PDT, ID: 21679153

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.

 
[+][-]05.30.2008 at 09:29AM PDT, ID: 21679263

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.

 
[+][-]05.30.2008 at 09:33AM PDT, ID: 21679307

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: Extensible Markup Language (XML), Programming for ASP.NET, ADO.Net Class Library
Tags: asp.net
Sign Up Now!
Solution Provided By: raterus
Participating Experts: 1
Solution Grade: A
 
 
[+][-]06.27.2008 at 08:40AM PDT, ID: 21884907

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.

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