请教高手一个问题:
我现在用VB与MS XML Parser进行DOM编程,我编写的books.xml文件是:
<?xml version="1.0"?>
<! DOCTYPE Books SYSTEM "books.dtd">
<Books>
<Book ISBN="7-111-07315-0">
<title>Professional XML</title>
<authors>
<author>Didier Martin</author>
<author>Mark Birbect</author>
<author>Mark Birbec</author>
</authors>
<price>95.00</price>
</Book>
<Book ISBN="7-302-02934-2">
<title>Guide to programming with MFC</title>
<authors>
<author>Peter Norton</author>
<author>RobMcGregor</author>
</authors>
<price>79.00</price>
</Book>
</Books>
books.dtd文件是:
<! ELEMENT Books(Book *)>
<! ELEMENT Book(title,authors,price)>
<! ELEMENT title(#PCDATA)>
<! ELEMENT authors(author *)>
<! ELEMENT author(#PCDATA)>
<! ELEMENT price(#PCDATA)>
<! ATTLIST Book ISBN CDATA #REQUIRED>
Form1.frm代码是:
Dim xDoc As MSXML2.DOMDocument
Dim path As String
Private Sub Form_Load()
path = App.path & "\"
End Sub
Private Sub Load_Click()
Set xDoc = New MSXML2.DOMDocument
xDoc.validateOnParse = True
xDoc.async = False
If (xDoc.load(path & "books.xml")) Then
MsgBox "Load documents successfully!"
xDoc.save (path & "save.xml")
Else
MsgBox xDoc.parseError.reason
End If
Set xDoc = Nothing
End Sub
运行之后 ,我在按Load时出现该位置不能为空的提示,不知道是什么原因?有哪们知道吗?