我一直在通過xsd進行XML驗證,但我仍然是新手。我嘗試驗證這個XML,它彈出我這個錯誤:cvc-elt.1:無法找到元素'customers'的聲明。 [5]XSD XML驗證:無法找到元素的聲明
<?xml version="1.0"?>
<customers xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://w3schools.com requested_customer.xsd">
<customer name="Vladimir Putin" address="St. Petersburg, wadim street 23, Russia"/>
</customers>
和XSD
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xs:element name="customers">
<xs:complexType>
<xs:sequence>
<xs:element name="customer">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="name"/>
<xs:attribute type="xs:string" name="address"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
感謝您的幫助!
你可以發佈XSD的內容嗎? –
在這裏,你去!它可能來自XSD? – Js30
xsi:schemaLocation =「錯誤NAMESPACE requested_customers.xsd」 - 您的模式應該具有targetNamespace屬性。此targetNamespace的值應該是您在schemaLocation值中使用的值。 –