xpath.SetValue(Map, XPath, [SelectionNamespace], [Repeating])


Maps a node from an XML map to a list column or range. Use SetValue when creating new lists or ranges from XML maps.




The XmlMap object to use for the mapping.


A string containing the XPath of the node to map to the list column or range.


A string containing the namespace prefix used in the preceding XPath. The namespace takes the form "xmlns: prefix= ' namespace '".


True indicates the mapping repeats; False indicates the mapping is to a single cell in a range. Must be True or omitted when mapping to a list column.

The SelectionNamespace argument is required only if the specified XPath uses a different namespace from that shown in the XML map. For example, the Orders_Map sample includes the namespace prefix ns1. Since this namespace is defined in the workbook, you can omit the SelectionNamespace argument, as shown here:

Set xmap = ThisWorkbook.XmlMaps("Orders_Map")
 [A10].XPath.SetValue xmap, _

If, however, the XPath uses a different prefix, you must define that new namespace prefix using SelectionNamespace, as shown here:

[A10].XPath.SetValue xmap, _
  "/ord:Orders/ord:Order/ns1:BillTo/ord:Address/ord:Street1", _

Use the Repeating argument to map a repeating node to a single cell. For example, the preceding code creates a list column at cell ...

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.