怎样解析带有命名空间的XML,我的语句如下:
Dim node As System.Xml.XmlNode
Dim tempnode As XmlNode
Dim resourcesNode As XmlNode
Dim xmlroot As XmlNode = document.DocumentElement
Dim nsmgr As XmlNamespaceManager = New XmlNamespaceManager(document.NameTable)
nsmgr.AddNamespace("xx","http://www.adlnet.org/xsd/adlcp_rootv1p2")
tempnode = xmlroot.SelectSingleNode("//xx:organizations/organization/title",nsmgr)
这个语句为什么解析不了带有命名空间的XML,具体应该怎样写啊?
回答:
每一层都要加前缀
"//xx:organizations/xx:organization/xx:title"