views:

71

answers:

1

xmlns:m="http://www.MangoDSP.com/mav/wsdl" as localfile:"ma.wsdl" xmlns:m0="http://www.MangoDSP.com/schema" as localfile:"MaTypes.xsd"

how can i validate it.

+1  A: 

I haven't done this in a while (years, really) and once again I'm posting from my Linux laptop, so please forgive the fuzziness.

private bool isValid;
private ArrayList exceptionList;

public bool Validate()
{
    isValid = true;
    exceptionList = new ArrayList();

    XmlTextReader reader;
    XmlSchema schema;
    XmlSchemaCollection schemas = new XmlSchemaCollection();

    reader = new XmlTextReader( "schema file 1" );
    schema = XmlSchema.Read( reader, new ValidationEventHandler( ValidationError ) );
    schemas.Add( schema );

    reader = new XmlTextReader( "schema file 2" );
    schema = XmlSchema.Read( reader, new ValidationEventHandler( ValidationError ) );
    schemas.Add( schema );

    reader = new XmlTextReader( "validate this file" );

    XmlValidatingReader validatingReader;

    validatingReader = new XmlValidatingReader( reader );
    validatingReader.ValidationEventHandler += new ValidationEventHandler( ValidationError );
    validatingReader.Schemas.Add( schemas );

    isValid = true;
    exceptionList = new ArrayList();

    while ( validatingReader.Read() );

    return isValid;
}

private void ValidationError( object sender, ValidationEventArgs e )
{
    isValid = false;
    exceptionList.Add( e.Exception );
}

You'll also want to do some error handling and resource cleanup.

uncle brad
THANKS i will try it.
Allen shen