I use the following code to create an XML file which generates declaration as follows:
<?xml version="1.0" encoding="utf-8"?>
<!--This file is an example of the object for Performance Enhancement. -->
<Jobs xmlns:xsi="http://ift.tt/Atvu06; xmlns:xsd="http://ift.tt/FPH52k;
<Job>
XmlSerializer x = new XmlSerializer(jobs.GetType(), new XmlRootAttribute("Jobs"));
string filename = @"C:\test.xml";
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.IndentChars = " ";
settings.NewLineChars = "\r\n";
settings.NewLineHandling = NewLineHandling.Replace;
using (XmlWriter xmlWriter = XmlWriter.Create(filename, settings))
{
xmlWriter.WriteComment("This is my comment ");
x.Serialize(xmlWriter, jobs);
xmlWriter.Close();
}
How do I modify code to generate declaration like the following:
<?xml version="1.0" encoding="utf-8"?>
<Jobs xmlns:xsi="http://ift.tt/Atvu06; xmlns=" http://ift.tt/1v2naCi; xsi:schemaLocation=" http://ift.tt/1zy9M0t ../xsd_schemas/obj_Job.xsd">
<!--This is my comment -->
<Job id="A1" id="A2" id="A3">
I would also like to add attribute to each element e.g.
<Job active="yes">Job #1</job>
No comments:
Post a Comment