|
Hi priya
this is my xsd file
<?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema.xsd" xmlns:mstns="http://tempuri.org/XMLSchema.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- -->
<xs:element name="Plan">
<xs:complexType>
<xs:sequence>
<xs:element name="Patient_Data">
<xs:complexType>
<xs:sequence>
<xs:element name="Name_of_Patient" type="xs:string" />
<xs:element name="Patient_ID" type="xs:string" />
<xs:element name="Clinical_Record" type="xs:string" />
<xs:element name="Site_of_Target_Vol" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="General_Data">
<xs:complexType>
<xs:sequence>
<xs:element name="Planned_on" type="xs:date" />
<xs:element name="Planned_by" type="xs:string" />
<xs:element name="Date_of_Protocol" type="xs:dateTime" />
<xs:element name="Number_of_Pages_Protocol" type="xs:int" />
<xs:element name="Image_Series_ID" type="xs:int" />
<xs:element name="Target_Point_Mode" type="xs:string" />
<xs:element name="Device_Coord_Syst" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
i want to display or print all the elements in the schema., the elements are like "plan" under this "Patient_data and General_data" and under patient_data it has some sub elements. How can i traverse all the elemetns in the file. I tried like this
XmlTextReader reader = new XmlTextReader(@"E:\XmlTest\Test\PatientData.xsd");
try
{
XmlSchema schema = XmlSchema.Read(reader, null);
schema.Compile(null);
if (schema.IsCompiled)
{
MessageBox.Show("Inside");
foreach (XmlSchemaElement parentElement in schema.Elements.Values)
{
MessageBox.Show(parentElement.Name.ToString());
XmlSchemaComplexType ct = parentElement.ElementType as XmlSchemaComplexType; //Casting to complex type
if (ct != null)
{
XmlSchemaSequence seq = (XmlSchemaSequence)ct.ContentTypeParticle;
foreach (XmlSchemaElement elem in seq.Items)
{
MessageBox.Show(elem.Name.ToString());
}
}
}
it displays only plan and patient_data and General_data it is not displaying sub elements. Can u please tell me where the problem is? share ur ideas
Thanks in advance
Regards
|