'設定XSD驗證-----------------------------------------------------------------
Sub validate(strxml)
Dim strs As String
strs = strxml
Dim xmlDoc, schema, schemaCache, parseErr
Set xmlDoc = CreateObject("Msxml2.DOMDocument.6.0")
'strs =放XML的路徑位置
xmlDoc.Load strs
Set schema = CreateObject("Msxml2.DOMDocument.6.0")
'sheet1.Cells(33, 2).Value= 放XSD的路徑位置
schema.Load sheet1.Cells(33, 2).Value
Set schemaCache = CreateObject("Msxml2.XMLSchemaCache.6.0")
schemaCache.Add "", schema
Set xmlDoc.Schemas = schemaCache
Set objErr = xmlDoc.validate()
If objErr <> 0 Then
MsgBox (objErr.reason)
Else
MsgBox ("Validate Sucessful")
End If
End Sub
PS:版本MS2010 ,我是沒有開啟Microsoft XML6.0 就可以執行,如果需要可在開發工具->工具->設定引用項目開啟
REF1
REF2
REF3
REF4
python REF5
REF6
REF7
REF8
REF9
REF10
REF11
沒有留言:
張貼留言