Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8291523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:09:32+00:00 2026-06-08T13:09:32+00:00

I have an xml. I have created one XSD for the xml. I want

  • 0

I have an xml.
I have created one XSD for the xml.

I want to write a prog to validate the xml against xsd.
I wrote a prog and got individual values am setting.

But is there a way, i can give the xml file as input and could see if the xml is valid against the XSD?

Thanks,
Nini

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T13:09:33+00:00Added an answer on June 8, 2026 at 1:09 pm

    This is an example of xml validation with XSD.

    public static boolean validate() {
        Source xmlFile = null;
        File schemaFile;
        SchemaFactory schemaFactory;
        Schema schema;
        try {
            schemaFile = new File(xsdFileName);
            xmlFile = new StreamSource(new File(xmlFileName));
            schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
            schema = schemaFactory.newSchema(schemaFile);
            Validator validator = schema.newValidator();
            validator.validate(xmlFile);
            System.out.println(xmlFile.getSystemId() + " is valid");
        } catch (SAXException | IOException e) {
            System.out.println(xmlFile.getSystemId() + " is NOT valid");
            System.out.println("Reason: " + e.getLocalizedMessage());
            return false;
        }
        return true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created two folders layout and layout-land with two xml files, one for
I have created an XML schema (foo.xsd) and used xjc to create my binding
I have an XSD that I created. A Transaction Header can one or more
I have two xml files and I need to create one xsd for both.
I have two XML examples that I want to write a schema for: Example
I have around 6 individual xsd schemas that define one complex type each. I
I have an XSD file and I want to create an XML file at
I have created XML file,but I can't view it/output it.I know there is no
I Have XML similar to this(omitted parts for brevity): <uformrecord> <state>Submitted</state> <created>2012-06-19T11:31:54</created> <updated>2012-06-19T11:32:13</updated> <id>53225sas3c1-d727-42cd-93a6-97cd778e5ee9</id>
I have created an xml file like this: <?xml version=1.0 encoding=utf-8?> <ListView xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=match_parent

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.