0
나는 다음과 같은 XML 파일이 XmlDocument
에로드 한 설정했을 때 불평 :XmlDocument.Validate는()의 targetNamespace는 XML의 스키마와 네임 스페이스 C#에서
<?xml version="1.0" encoding="ISO-8859-1"?>
<shiporder orderid="889923" xmlns="http://www.example.com">
<orderperson>John Smith</orderperson>
<shipto>
<name>Ola Nordmann</name>
<address>Langgt 23</address>
<city>4000 Stavanger</city>
<country>Norway</country>
</shipto>
<item>
<title>Empire Burlesque</title>
<note>Special Edition</note>
<quantity>1</quantity>
<price>10.90</price>
</item>
<item>
<title>Hide your heart</title>
<quantity>1</quantity>
<price>9.90</price>
</item>
</shiporder>
그리고 나는 그것을 검증이 스키마를 사용 :
요소 네임 스페이스에 'shiporder' 'HTT :
<?xml version="1.0" encoding="ISO-8859-1" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com"> <xs:element name="shiporder"> <xs:complexType> <xs:sequence> <xs:element name="orderperson" type="xs:string"/> <xs:element name="shipto"> <xs:complexType> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:element name="address" type="xs:string"/> <xs:element name="city" type="xs:string"/> <xs:element name="country" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="item" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="title" type="xs:string"/> <xs:element name="note" type="xs:string" minOccurs="0"/> <xs:element name="quantity" type="xs:positiveInteger"/> <xs:element name="price" type="xs:decimal"/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name="orderid" type="xs:string" use="required"/> </xs:complexType> </xs:element> </xs:schema>
그것은
은NoticeEventArgs.Message
에서이 메시지를 제공합니다 p : //www.example.com '에 하위 필드'orderperson '이 (가) 'http://www.example.com '네임 스페이스에 있습니다. 예상 가능한 요소 목록 : 'orderperson'.
그러나 XSD 파일에서 XML 파일과 targetNamespace
의 네임 스페이스를 제거하면 유효성 검사가 통과됩니다. 어떻게 그렇게하고 그것을 고치는 법? 감사!
효과가있었습니다. 감사! – Dan7