Frinavale,
XmlSchemaValidator is for XSD file validation and my XML is of type XDR. I have used XMLValidatingReader to validate this eventhough it is obselate in .NET 2.0 as
XMLSchemaSet doesnt support XDR format .
Following is my input Test.xml
-
<?xml version="1.0" ?>
-
<Test xmlns="x-schema:MySchema.xml" xmlns:Test="x-schema:TestSchema.xml" xmlns:Testid="x-schema:TestIdSchema.xml">
-
<Info>
-
<Information name="Myname" address="2"/>
-
</Info>
-
</Test>
-
validation part i have done like this:
-
XmlSchemaCollection xsc = new XmlSchemaCollection();
-
xsc.Add("x-schema:MySchema.xml", @"C:\MySchema.xml");
-
xsc.Add("x-schema:TestSchema.xml", @"C:\TestSchema.xml");
-
XmlTextReader tr = new XmlTextReader(@"C:\Test.xml");
-
XmlValidatingReader vr = new XmlValidatingReader(tr);
-
vr.ValidationType = ValidationType.XDR;
-
vr.Schemas.Add(xsc);
-
vr.ValidationEventHandler += new ValidationEventHandler(ValidationHandler);
-
while (vr.Read()) ;
-
I want to read attribute values of "name" and "address" from input xml. Please answer how to proceed further.
can i use XMLDocument to do this using "SelectSingleNode" and "Attributes.GetNamedItem"? for this i need to assign validated schemas to XMLDocument object. but XMLDocument object uses XMLSchemaSet while XmlValidatingReader uses XmlSchemaCollection.
Please send me sample code to parse this XML document.