April 2006
Beginner
1114 pages
98h 16m
English
Use the XPath object’s SetValue method to map data from an XML map to a list column or range. SetValue allows you to dynamically create lists from an XML map. For example, the following code creates a new list, adds three columns to that list, and maps each column to a different node in an XML map:
Set ws = ThisWorkbook.Sheets("Sheet1")
Set xmap = ThisWorkbook.XmlMaps("Numbers_Map")
' Create a list object.
Set lo = ws.ListObjects.Add(xlSrcRange, [A1])
' Add a column to the list.
Set lc = lo.ListColumns.Add
' Map the column to an element in an XML map.
lc.XPath.SetValue xmap, "/Numbers/Number/One", , True
' Repeat for two more columns.
Set lc = lo.ListColumns.Add
lc.XPath.SetValue xmap, "/Numbers/Number/Two", , True
Set lc = lo.ListColumns.Add
lc.XPath.SetValue xmap, "/Numbers/Number/Three", , TrueRead now
Unlock full access