我试图通过 Vb 脚本在 xml DOM 中使用函数 getNamedItem,但它永远不会工作。下面是一段代码和 XML 文档。请帮助我找出错误,在此先感谢。
Set obj = CreateObject("Microsoft.xmldom")
obj.async = false
obj.load ("C:\Users\ACER\Desktop\Project Folder\Parsing XML\Books.xml")
Set root = obj.documentElement
Set child = root.childNodes
Set Node = child.item(1)
s=Node.getNamedItem('author')
Msgbox s
XML 文件:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<bookstore>
<book category="cooking">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="children">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
</bookstore>