roipatrick
New Member
- Joined
- Mar 20, 2014
- Messages
- 39
I have a sheet which can be mapped as XML and it is running well. But I want to map a certain column which will become the childnode of a tag.
A normal XML tag is shown below
Now, what I'm trying to accomplish is something like this
Here's the mapping code of my excel sheet to become exportable into XML file
Now, How can I add a column let's say G coloumn in excel as their child node.
Table show below
<tbody>
</tbody>
A normal XML tag is shown below
Code:
<entry>
<animal ID>
<animal name>
<animal group>
</entry>
Now, what I'm trying to accomplish is something like this
Code:
<entry no="1"> <------Theres a column in my excel which i created to be the child node but im finding it hard to do it
<animal ID>
<animal name>
<animal group>
</entry>
Here's the mapping code of my excel sheet to become exportable into XML file
Code:
ActiveWorkbook.Sheets("Animals").Activate ActiveSheet.EnableCalculation = False
Dim oMyMap As XmlMap
Dim strXPath As String
Dim oMyList As ListObject
Dim oMyNewColumn As ListColumn
' Add a schema map.
' ThisWorkbook.XmlMaps.Add (ThisWorkbook.Path & "\Myschema.xsd")
ThisWorkbook.XmlMaps.Add ("C:\Users\1443\Desktop\grouping\schema.xml")
' Identify the target schema map.
Set oMyMap = ThisWorkbook.XmlMaps("Animal_Map")
' Create a new list in A1.
Range("A1").Select
Set oMyList = ActiveSheet.ListObjects.Add
strXPath = "/Animal/entry/AnimalId"
oMyList.ListColumns(1).XPath.SetValue oMyMap, strXPath
Set oMyNewColumn = oMyList.ListColumns.Add
strXPath = "/Animal/entry/AnimalName"
oMyList.ListColumns(2).XPath.SetValue oMyMap, strXPath
Set oMyNewColumn = oMyList.ListColumns.Add
strXPath = "/Animal/entry/AnimalGroup"
oMyList.ListColumns(3).XPath.SetValue oMyMap, strXPath
oMyList.ListColumns(1).Name = "AnimalID" oMyList.ListColumns(2).Name = "AnimalName"
oMyList.ListColumns(3).Name = "AnimalGroup"
Now, How can I add a column let's say G coloumn in excel as their child node.
Table show below
A | B | C | D | E | F | G |
Animal Id | Animal Name | Animal Group | No | |||
123 | Dog | Canine | 1 | |||
122 | Cat | Feline | 2 | |||
121 | Snake | Reptile | 3 |
<tbody>
</tbody>