PHP DOMDocument checks for compliance with XSI schema

I have a problem checking this XML file in PHP. This works with the given $ myFile xsi schema:

function validate($file){
    $xsi = $myFile;
    if(@!$this->dom->schemaValidate($xsi)){
        $warning = error_get_last();
        throw new Exception ('XML validation of file "'.$this->file.'" failed: '.$warning['message']);
    }
}

But how can I use a link scheme from an XML file?

<?xml version="1.0" encoding="UTF-8"?>

<item xsi:noNamespaceSchemaLocation="http://my.server.com/schema.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

Thank you for your help.

+3
source share

Source: https://habr.com/ru/post/1771536/


All Articles