Excel VBA映射过滤XML到表

我有下面的代码,将XML架构映射到Excel表(如在ListObjects中)。

Sub MapXMLFieldsToExcelCells(wb As Workbook, sLOB As String) '******************************************************************* '** Name: xmlFieldMap '** Purpose: Maps fields of existing xlmMap (named "xmlData") to file '** Dependents: TieXMLToExcel (remapping of xml file) '** Notes: '******************************************************************* sProcName = "MapXMLFieldsToExcelCells" With wb Dim xMap As XmlMap Set xMap = .XmlMaps(sLOB) Dim wsXMLMain As Worksheet Set wsXMLMain = .Worksheets("xml" & IIf(Left(.Name, 2) = "SA", "SA", "") & sLOB) Dim wsConfig As Worksheet Set wsConfig = .Worksheets("rConfig") With wsConfig Dim rNode As Range For Each rNode In .Range("xmlNodeMapping").Columns(1).Cells Dim sNodePath As String sNodePath = rNode & rNode.Offset(, 1) Dim sTable As String sTable = rNode.Offset(, 2) 'only have this here in case node does not exist 'caveat is that it will fail also if node is just written out wrong Application.DisplayAlerts = False 'On Error Resume Next wsXMLMain.ListObjects(sTable).ListColumns(rNode.Offset(, 3).Value2).XPath.SetValue xMap, sNodePath 'On Error GoTo ErrorReport Application.DisplayAlerts = True Next End With .XmlMaps(sLOB).DataBinding.Refresh End With End Sub 

(请忽略项目特定的行 – 这里不是太多)

代码很好。 我可以映射节点和节点的属性,如果我通过configuration表如下所示:

 Xpath Node Table Field /root/d/p/t/ ar tForms AR /root/d/p/t/ @n tFormsa name 

我想要做的是,如果可能的话,在节点上应用filter,以仅映射节点的某些元素。

例如,基于正确的语法:

 Xpath Node Table Field /root/d/p/t[item='ar']/ type tForms type 

只会拉动节点t中的元素= ar。

我无法得到这个工作,在网上找不到任何东西,我可以接受的是,这是不是一种select,但想放弃之前的方式。