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 8516269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:22:41+00:00 2026-06-11T05:22:41+00:00

I have two files: A sample XML file. A .xsd file w/ schema, which

  • 0

I have two files:

  • A sample XML file.
  • A .xsd file w/ schema, which the aforementioned XML file must adhere to.

To validate the XML file against the schema, I’ve been using:

$dom = new DOMDocument();

//$this->xmlstr; is my XML file after being loaded into a string.
$dom->loadXML($this->xmlstr); 

//$xsd_file is definitely my xsd file.
if(!$dom->schemaValidate($xsd_file)){
     $errors = libxml_get_errors(); //supposed to give back errors?
     var_dump($errors); //debugging - shows: array empty
}

However, I keep getting warning errors whenever my XML doc doesn’t adhere to the rules in the schema.

Warning: DOMDocument::schemaValidate() [domdocument.schemavalidate]:
Element ‘Header’: This element is not expected. Expected is ( Routing )

I’ve been intentionally screwing up my XML file, just to see how $dom->schemaValidate actually handles it. Obviously, I don’t want PHP spitting out warning messages onto the page whenever the XML doesn’t meet the schema. Instead, I’d like my app to take care of that. Am I overlooking something here?

  • 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-11T05:22:43+00:00Added an answer on June 11, 2026 at 5:22 am

    You must call

    libxml_use_internal_errors(true);
    

    before creating new DOMDocument() in order to suppress warnings and start collecting XML parsing errors into internal structure accessible via libxml_get_errors().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been tasked with splitting an XML file into two parts for ease
Lets say I have a two websites www.sample.com and files.sample.com. In an .htaccess file
I have two files client.php and server.php. The client file send a HTTP request
I have two files: domainList and config.cnf. The domainList file simply has a list
I have two files called file_utils.h and file_utils.cpp which contain some methods and variables
I have two files which both contain a list of words. Is there an
I have a sample xml file that looks like this: <Books> <Category Genre=Fiction BookName=book_name
I need to find a way to join two XML files when they have
I have an xml file which looks like the below example <Ids> <Id> <set>ai</set>
I have to compare XML data. There are two sources- Web Service XML files

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.