OK I've now entered reentered the code and I still get the error. Here is
the code.
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using System.IO;
using System.Text;
namespace XML_test1
{
public partial class Form1 : Form
{
public Form1()
{
ArrayList temp = new ArrayList();
temp.Add("1");
BatchHeader test = new BatchHeader(temp);
InitializeComponent();
try
{
XmlSerializer x = new XmlSerializer(typeof(BatchHeader));
TextWriter writer = new StreamWriter("\\Program Files\\log scale manager
2\\" + "HBS.xml");
x.Serialize(writer, test);
MessageBox.Show("Done");
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
}
public class BatchHeader
{
public string ScaleSite;
public string FromScaleDate;
public string ToScaleDate;
public string SubmitterBatchID;
[System.Xml.Serialization.XmlElementAttribute(DataT ype = "integer")]
public string DocumentCount;
[System.Xml.Serialization.XmlElementAttribute(DataT ype = "integer")]
public string BatchControlTotal;
public BatchHeader(ArrayList batchLoads)
{
string[] BatchInfo;
ScaleSite = "First";
FromScaleDate = "Second";
ToScaleDate = "Third";
SubmitterBatchID = "fourth";
DocumentCount = "5";
BatchControlTotal = "6";
}
// default constructor needed for serializing
public BatchHeader()
{
}
}
}
And here is the result
<?xml version="1.0" encoding="utf-8"?>
<BatchHeader xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SubmitterBatchID>fourth</SubmitterBatchID>
<DocumentCount>5</DocumentCount>
<BatchControlTotal>6</BatchControlTotal>
<ScaleSite>First</ScaleSite>
<FromScaleDate>Second</FromScaleDate>
<ToScaleDate>Third</ToScaleDate>
</BatchHeader>
This is all created in VS 2005, testing is being done on a Pocket PC
device. It's the same if I use the pocket pc 2003 emulator.
"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:33****************@TK2MSFTNGXA01.phx.gbl...
Hi Jamie,
I'm using the same code you have used. And I get the xml file in the
correct order.
<?xml version="1.0" encoding="utf-8" ?>
<BatchHeader xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ScaleSite>First</ScaleSite>
<FromScaleDate>second</FromScaleDate>
<ToScaleDate>third</ToScaleDate>
<SubmitterBatchID>4</SubmitterBatchID>
<DocumentCount>5</DocumentCount>
<BatchControlTotal>sixth</BatchControlTotal>
</BatchHeader>
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."