XML Validation against XSD in PHP libxml

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

I have created an xml like below


    Logon
    23424
             


        
相关标签:
2条回答
  • 2021-02-15 00:21

    Just close your xsd file:

    </xsd:schema>
    

    I try it now, and for me this works.

    0 讨论(0)
  • 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

    0 讨论(0)
提交回复
热议问题