<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3school.com.cn" xmlns="http://www.w3school.com.cn" elementFormDefault="qualified"> <xs:element name="note"> <xs:complexType> <xs:sequence> <xs:element name="to" type="xs:string"/> <xs:element name="from" type="xs:string"/> <xs:element name="heading" type="xs:string"/> <xs:element name="body" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
xml文件:
<?xml version="1.0"?> <note xmlns="http://www.w3school.com.cn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3school.com.cn note.xsd"> <to>George</to> <from>John</from> <heading>Reminder</heading> <body>Don't forget the meeting!</body> </note>
- 这样的关系,谁负责来验证xml是否符合xsd规则?是程序员自己实现?
- 如果我用浏览器访问xml文件,浏览器会校验么?
- 如果程序员自己实现,那么xsd文件如何让代码获取?
xsi:schemaLocation="http://www.w3school.com.cn note.xsd">
- 这行代码中的note.xsd和note.xml的位置关系是啥?
另外,非IE浏览器下打开xml文档总是提示:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
- 这个如何解决?
xml 声明里有一个属性 xs:schemaLoaction