复制代码
- <?xml version="1.0" encoding="GB2312"?>
- <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
- <xs:element name="n">
- <xs:complexType>
- <xs:all>
- <xs:element name="s">
- <xs:complexType>
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute name="NOTATION">
- <xs:simpleType>
- <xs:restriction base="xs:NOTATION">
- <xs:enumeration value="jpg"/>
- </xs:restriction>
- </xs:simpleType>
- </xs:attribute>
- <xs:attribute name="ENTITY1" type="xs:ENTITY"/>
- <xs:attribute name="ENTITIES1" type="xs:ENTITIES"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- </xs:element>
- </xs:all>
- </xs:complexType>
- </xs:element>
- <xs:notation name="jpg" public="image/jpeg" system="viewer.exe"/>
- <xs:notation name="mp3" public="image/jpeg" system="viewer.exe"/>
- </xs:schema>
复制代码
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE n [
- <!NOTATION jpg SYSTEM "image/jpeg">
- <!NOTATION mp3 SYSTEM "wmplayer.exe">
- <!ENTITY f1 SYSTEM "1.jpg" NDATA jpg>
- <!ENTITY f2 SYSTEM "1.mp3" NDATA mp3>
- <!ELEMENT n ANY>
- <!ELEMENT s ANY>
- <!ATTLIST s NOTATION (jpg) #REQUIRED
- ENTITY1 ENTITY #REQUIRED
- ENTITIES1 ENTITIES #REQUIRED>
- ]>
- <n>
- <s NOTATION="jpg"
- ENTITY1="f1"
- ENTITIES1="f1 f2"/>
- </n>
复制代码
- Option Explicit
- Dim oDOMDocument, oXSD, oXMLDOMElement
- Set oXSD = CreateObject("Msxml2.XMLSchemaCache.6.0")
- oXSD.add "", "1.xsd"
- Set oDOMDocument = CreateObject("Msxml2.DOMDocument.6.0")
- oDOMDocument.setProperty "ProhibitDTD", "false"
- oDOMDocument.setProperty "ResolveExternals", "True"
- oDOMDocument.validateOnParse = True
- oDOMDocument.schemas = oXSD
- oDOMDocument.load "1.xml"
- If oDOMDocument.parseError.errorCode <> 0 Then '如果加载xml出错
- MsgBox oDOMDocument.parseError.reason & vbLf & _
- "第 " & oDOMDocument.parseError.line & " 行"
- WScript.Quit()
- End If
- MsgBox oDOMDocument.xml
- Set oXMLDOMElement = oDOMDocument.documentElement '根节点
- MsgBox oXMLDOMElement.SelectNodes("s")(0).getAttribute("NOTATION") & vbLf & _
- oXMLDOMElement.SelectNodes("s")(0).getAttribute("ENTITY1") & vbLf & _
- oXMLDOMElement.SelectNodes("s")(0).getAttribute("ENTITIES1")
欢迎光临 批处理之家 (http://bbs.bathome.net/) | Powered by Discuz! 7.2 |