如何在 php 中使用 XSD 模式 [英] How to use an XSD schema in php

查看:25
本文介绍了如何在 php 中使用 XSD 模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用 XSD 架构来开发从酒店接收预订的 Web 服务.我有 xsd 的网址.这是 OTA_HotelResNotifRQ.

I need to use an XSD schema to develop a Web Service that receive reservations from an Hotel. I've the url of the xsd. This is the OTA_HotelResNotifRQ.

我不知道如何开始.有人可以帮我吗?

I don't know how to begin with this. Someone can help me?

谢谢

推荐答案

几乎一直可用的 PHP DOM 扩展可以在本机执行此操作.

The PHP DOM extension, which is available almost all the time can do this natively.

$dom = new DomDocument;
$dom->loadXML($contentOfResponse);
if ($dom->schemaValidate('path/to/schema.xsd')) {
    // Valid response from service
} else {
    // Invalid response
}

当然,您也可以从文件中加载要验证的文档.

Of course, you can also load the document to validate from a file.

文档:http://ca.php.net/manual/en/domdocument.schemavalidate.php

这篇关于如何在 php 中使用 XSD 模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆