如何到达vbscript中元素XML的第二个子节点?

如何到达vbscript中元素XML的第二个子节点?,vbscript,asp-classic,Vbscript,Asp Classic,在互联网上花了很多小时后,我无法让它工作,需要一些帮助 XML: 代码: 问题: 正如图像XML中强调的那样,我需要能够读取“NoteSynopsis”元素及其值。虽然这看起来很简单,但我还没有找到解决办法。如果这是最后一个没有问题的孩子,我会做Elem.LastChild.nodename,但这不是 您可以使用selectSingleNode(…)方法并使用XPath set xmlDoc = SERVER.CREATEOBJECT("MSXML2.DomDocument.6.0") xm

在互联网上花了很多小时后,我无法让它工作,需要一些帮助

XML:

代码:

问题:
正如图像XML中强调的那样,我需要能够读取“NoteSynopsis”元素及其值。虽然这看起来很简单,但我还没有找到解决办法。如果这是最后一个没有问题的孩子,我会做Elem.LastChild.nodename,但这不是

您可以使用
selectSingleNode(…)
方法并使用XPath

set xmlDoc  = SERVER.CREATEOBJECT("MSXML2.DomDocument.6.0")
xmlDoc.async = False              xmlDoc.Load("D:\GVPApplications\TechSupportCreateIncident\CreateIncidentRequest.xml")    
xmlDoc.setProperty "NewParser","true"
xmlDocument.setProperty "SelectionLanguage", "XPath"               

Dim firstIncidentNote
set firstIncidentNote = xmlDoc.SelectSingleNode("//IncidentNote")
Dim note
Dim noteSynopsis
set note = firstIncidentNote.GetAttribute("Note")
set note = firstIncidentNote.GetAttribute("NoteSynopsis")

您正在上载xml文件吗?我可以测试我的计算机。SelectSingleNode的问题是它解析元素的第一个值(在本例中为IncidentNote)。如果我有多个元素IncidentNote,如何说出第二个IncidentNote。例如,您可以编写:
xmlDoc.SelectNodes(“//IncidentNote”)[1]
set xmlDoc  = SERVER.CREATEOBJECT("MSXML2.DomDocument.6.0")
xmlDoc.async = False              xmlDoc.Load("D:\GVPApplications\TechSupportCreateIncident\CreateIncidentRequest.xml")    
xmlDoc.setProperty "NewParser","true"
xmlDocument.setProperty "SelectionLanguage", "XPath"               

Dim firstIncidentNote
set firstIncidentNote = xmlDoc.SelectSingleNode("//IncidentNote")
Dim note
Dim noteSynopsis
set note = firstIncidentNote.GetAttribute("Note")
set note = firstIncidentNote.GetAttribute("NoteSynopsis")