Validate an XML file with a given XSD file
이전 댓글 표시
Hello,
Are there any tools in Matlab that will check that an xml file coforms to a given xml schema (.xsd) file?
Thanks!
답변 (2개)
Wil Koenen
2020년 2월 6일
You can call Java libraries from MATLAB.
schemaFileName = "MySchema.xsd";
xmlFileName = "MyXML.xml";
schemaFile = java.io.File(schemaFileName);
xmlFile = java.io.File(xmlFileName);
schemaFactory = javax.xml.validation.SchemaFactory.newInstance(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI);
schema = schemaFactory.newSchema(schemaFile);
validator = schema.newValidator();
fileInputStream = java.io.FileInputStream(xmlFile);
streamSource = javax.xml.transform.stream.StreamSource(fileInputStream);
validator.validate(streamSource); % throws an exception if not valid
Hari Krishna Ravuri
2019년 11월 5일
0 개 추천
As of now, there is no in-built function in MATLAB to validate the given XML file with the XSD given by the user.
카테고리
도움말 센터 및 File Exchange에서 Structures에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!