[英]VB.Net Validate an xml against a schema (strange problem)
我寫了一個小的XML驗證器,它接收XML文件和XML模式,並根據該模式驗證XML文件。 除了具有以下內容的XML文件外,它運作良好:
<?xml version="1.0" encoding="utf-8"?>
<xc:program xmlns:xc="http:\\www.something.com\Schema\XC10" xc:version="4.0.22.0" >
<xc:namespaceDecls>
<xc:namespaceDecl xc:namespaceDeclURI="urn:swift:xsd:abc">
<xc:namespaceDeclPrefix>n</xc:namespaceDeclPrefix>
</xc:namespaceDecl>
</xc:namespaceDecls>
</xc:program>
我試圖針對一堆不同的模式來驗證該XML文件。 無論我選擇哪種模式,該XML文件都是有效的。 我想念的是什么? 這是相關的代碼段:
//'Create a schema cache and add the given schema to it.
Dim schemaCache As New Schema.XmlSchemaSet
schemaCache.Add(targetNamespace, schemaFilename)
//'Create an XML DOMDocument object.
Dim xmlDom As New XmlDocument
//'Assign the schema cache to the DOM document.
//'schemas collection.
xmlDom.Schemas = schemaCache
//'Load selected file as the DOM document.
xmlDom.Load(xmlFilename)
xmlDom.Validate(AddressOf ValidationCallBack)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.