Is there a way to validate only a part of XML file using XSD file and ignore the other contents of the XML file. I want to validate only a couple of tags in XML file using XSD file. My XML file contains many tags, but xsd contains elements for only few of the tags.
Is it possible to attain this somehow?
There are two ways (at least) to achieve this, in principle.
First, you can in principle tell the validator which elements in the document you want to validate; the XSD spec does not require validation to start at the document root. In practice, command-line validators almost never provide run-time options for starting validation anywhere but the root. I think validation libraries are more likely to provide that functionality; they often (or at least sometimes) provide functions to allow you to pass in the element at which validation should start, together with the necessary schema information.
If your validator doesn’t allow you to validate selectively, you can write a schema that contains declarations for just those elements and attributes you want to validate, and invoke a validator on the document root in “lax validation mode” — which means, essentially “If you find in the schema a declaration for an element in the document, then validate the element against its declaration, otherwise accept it (pretend it matches a lax wildcard in the declaration of its parent) and move on.” The validator will thus ignore elements for which you provide no declarations and validate elements for which you do provide declarations. (Note that conforming XSD processors are not required to provide lax-validation mode, and the definition of lax validation in the spec is a little underspecified, but I believe most available processors do support it and do the same thing in lax mode.)