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

  • Home
  • SEARCH
  • 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 8681057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:24:26+00:00 2026-06-12T21:24:26+00:00

I want to validate XML files against an XSD on iOS. The documentations alludes

  • 0

I want to validate XML files against an XSD on iOS. The documentations alludes to using NSXMLDocument to do this, but its not available on iOS =(. Are there any light weight alternatives to do this on iOS?

  • 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-12T21:24:28+00:00Added an answer on June 12, 2026 at 9:24 pm

    I ended up using the validation facilities in libxml2 since its a library already included in iOS. Following this sample code

    #include <libxml/parser.h>
    #include <libxml/xmlschemas.h>
    
    int is_valid(const xmlDocPtr doc, const char *schema_filename)
    {
        xmlDocPtr schema_doc = xmlReadFile(schema_filename, NULL, XML_PARSE_NONET);
        if (schema_doc == NULL) {
            /* the schema cannot be loaded or is not well-formed */
            return -1;
        }
        xmlSchemaParserCtxtPtr parser_ctxt = xmlSchemaNewDocParserCtxt(schema_doc);
        if (parser_ctxt == NULL) {
            /* unable to create a parser context for the schema */
            xmlFreeDoc(schema_doc);
            return -2;
        }
        xmlSchemaPtr schema = xmlSchemaParse(parser_ctxt);
        if (schema == NULL) {
            /* the schema itself is not valid */
            xmlSchemaFreeParserCtxt(parser_ctxt);
            xmlFreeDoc(schema_doc);
            return -3;
        }
        xmlSchemaValidCtxtPtr valid_ctxt = xmlSchemaNewValidCtxt(schema);
        if (valid_ctxt == NULL) {
            /* unable to create a validation context for the schema */
            xmlSchemaFree(schema);
            xmlSchemaFreeParserCtxt(parser_ctxt);
            xmlFreeDoc(schema_doc);
            return -4; 
        }
        int is_valid = (xmlSchemaValidateDoc(valid_ctxt, doc) == 0);
        xmlSchemaFreeValidCtxt(valid_ctxt);
        xmlSchemaFree(schema);
        xmlSchemaFreeParserCtxt(parser_ctxt);
        xmlFreeDoc(schema_doc);
        /* force the return value to be non-negative on success */
        return is_valid ? 1 : 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to validate an XML file against an XSD schema. The XML files
I want to validate large xml files by using xsd schemas in C#. For
I want to validate xml against xsd file. So I would like to install
I got a simple XML file that I want to validate against an XSD.
I want to validate XML against XSD file and get errors if there is
I want to validate an XML file against an XML Schema file. It is
Very basic question- I've a xml file and I want to validate it against
I am trying to validate an XML against schema using LibXML::Schema Validator CPAN module.
Is there a way to validate only a part of XML file using XSD
I wrote this code to validate my xml file via a xsd def parseAndObjectifyXml(xmlPath,

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.