I've managed to write
VB-code that creates an XMLMap using code like this
(...
Set LoXMLMap = LoWorkbook.XmlMaps.Add(XSDFileName, MAP_ROOTNODE
LoXMLMap.Name = MAP_NAM
After that, I map the columns using a loop where each iteration does the following
LoWorkbook.ActiveSheet.Range(LsPrefix & LsCol & "1").XPath.setValue
LoWorkbook.XmlMaps(MAP_NAME),
"/" & MAP_ROOTNODE & "/doc/Element/@" & GsAttributes(LiCount), , Tru
Finally I import my data to the map
LoWorkbook.XmlMaps(MAP_NAME).Import PsTransformedXMLDoc, Tru
All works well except one detail: For those rows that don't have an attribute X, I would expect Excel to leave the cell in the corresponding cell empty. However, as soon as a row shows up that has the attribute X, the attribute's value is not entered on the row where it belongs, but in the first unused cell of the column
Say my data in the xml file is as follows
<Person Name="Paul" Job="Cassier"<Person Name="John" Phone="123456"<Person Name="Peter" Job="Butcher" Phone="234567"
Note that Paul has no Phone attribute and John has no Job attribute
What I expect
Name Job Phon
Paul Cassier
John 12345
Peter Butcher 23456
What I get
Name Job Phon
Paul Cassier 12345
John Butcher 23456
Peter
Anyone any ideas on how I can force the right content from VBA?