TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Matt Donnelly
NA
4
1.8k
Having trouble with C# XmlSerializer
Apr 12 2015 2:07 PM
Ok so i have spend two days trying to work this out, i need my XML to be in the same format so that i can load in back though my form .
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfBike xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<bike>
<Make>Honda</Make>
<Model>CBR</Model>
<Year>2011</Year>
<Capacity>1000</Capacity>
</bike>
<bike>
<Make>Yamaha</Make>
<Model>YZ</Model>
<Year>2009</Year>
<Capacity>900</Capacity>
</bike>
<bike>
<Make>Suzuki</Make>
<Model>GB</Model>
<Year>2009</Year>
<Capacity>650</Capacity>
</bike>
</ArrayOfBike>
This is my code i have,
its for a windows form
XmlDocument doc = new XmlDocument();
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
XmlWriter writer = XmlWriter.Create("C:\\Temp\\mybikes.xml",settings);
writer.WriteStartDocument();
writer.WriteStartElement("Bike");
foreach (string item in listBikes.Items)
{
string encodedXml = item.Replace(""", " ");
writer.WriteStartElement("Make");
writer.WriteStartElement("Model");
writer.WriteStartElement("Size");
writer.WriteStartElement("Year");
writer.WriteStartElement("Cost");
writer.WriteAttributeString("Bike", encodedXml);
writer.WriteEndElement();
}
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Flush();
writer.Close();
// Save the document to a file and auto-indent the output.
System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(listBikes.GetType());
Reply
Answers (
1
)
There are mistakes in my Arrays Spreedsheet application
adding data in combobox from database