XML Validation against XSD in PHP libxml

前端 未结 2 675
隐瞒了意图╮
隐瞒了意图╮ 2021-02-14 23:33

I have created an xml like below


    Logon
    23424
             


        
2条回答
  •  梦谈多话
    2021-02-15 00:22

    dom specially gives two functions to validate with schema. One is to give file path

    $doc = new DOMDocument();
    $doc->load('PATH TO XML');
    
    $is_valid_xml = $doc->schemaValidate('PATH TO XSD');
    

    or else you could use

    $is_valid_xml = $doc->schemaValidateSource($source)
    

    This source should be a string containing the schema. It seems that you are using schemaValidateSource function other than schemaValidate. (Once I was stuck in the same place) cheers

提交回复
热议问题