Vijay Jadhav

Vijay Jadhav

  • NA
  • 15
  • 0

ASP.Net : Xml Version Format

May 18 2009 6:46 AM
Hi Experts,

My Xml format is :

<Sis>
<Student>
<StudentID>1</StudentID>
<AcademicDetails>2008-2009</AcademicDetails>
<PersonalDetails>
<FirstName>Vijay</FirstName>
<MiddleName>Laxmanrao</MiddleName>
<LastName>Jadhav</LastName>
</PersonalDetails>
</Student>
</Sis>


I have seen lot of Xml's with Version information ie <? xml version="1.0" ?>.

My question is that what is a cause that my Xml didn't show version and other information.

My Sample code behind for creating Xml is :

        #region Create Student Xml String
/* ---------------------------------------------------------- Create Student Xml File --------------------------------------------------------------------- */

private string sCreateStudentXml()
{
try
{
Consumer.Sis studentDS = new Consumer.Sis();
Sis.StudentRow student_row = studentDS.Student.NewStudentRow();

student_row.StudentID = 1;
student_row.AcademicDetails = "2008-2009";

studentDS.Student.AddStudentRow(student_row);

Sis.PersonalDetailsRow sub_StudentPersonalDetails_row = studentDS.PersonalDetails.NewPersonalDetailsRow();

sub_StudentPersonalDetails_row.FirstName = "Vijay";
sub_StudentPersonalDetails_row.MiddleName = "Laxmanrao";
sub_StudentPersonalDetails_row.LastName = "Jadhav";
sub_StudentPersonalDetails_row.StudentRow = student_row;
studentDS.PersonalDetails.AddPersonalDetailsRow(sub_StudentPersonalDetails_row);

// Accept the changes
studentDS.AcceptChanges();

System.IO.StringWriter writer = new System.IO.StringWriter();

studentDS.WriteXml(writer, System.Data.XmlWriteMode.WriteSchema);
return writer.ToString();
}
catch (Exception ex)
{
throw ex;
}
}

#endregion


And my Xsd is :

<?xml version="1.0" encoding="utf-8" ?>
<!--Created with Liquid XML Studio - 30 Day Trial Edition (http://www.liquid-technologies.com)-->
<xsd:schema id="Sis" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name="StudentPersonalDetails">
<xsd:sequence>
<xsd:element name="FirstName" type="xsd:string" />
<xsd:element name="MiddleName" type="xsd:string" />
<xsd:element name="LastName" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="StudentType">
<xsd:sequence>
<xsd:element name="StudentID" type="xsd:int" />
<xsd:element name="AcademicDetails" type="xsd:string" />
<xsd:element name="PersonalDetails" type="StudentPersonalDetails" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ParentPersonalDetails">
<xsd:sequence>
<xsd:element name="FirstName" type="xsd:string" />
<xsd:element name="MiddleName" type="xsd:string" />
<xsd:element name="LastName" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ParentType">
<xsd:sequence>
<xsd:element name="ParentID" type="xsd:int" />
<xsd:element name="ParentPersonalDetails" type="ParentPersonalDetails" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="Sis">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Student" type="StudentType" />
<xsd:element name="Parent" type="ParentType" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>


Please help! If anyone know please reply.

Note : I have created above Xml against Xsd.

Thanks.