Results 1 to 10 of 25

Thread: Need help to convert Excel data to XML

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Feb 2021
    Posts
    12
    Rep Power
    0
    Hi Sandy,

    The exported xml file looks like -

    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <DataImport xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    	<forecast>
    		<Entity>700</Entity>
    		<data>
    			<date>
    				<day>19</day>
    				<month>2</month>
    				<year>2021</year>
    			</date>
    			<period recID="7001">
    				<time>8:00</time>
    				<ItemSold>23</ItemSold>
    				<Price>119</Price>
    			</period>
    		</data>
    	</forecast>
    	<forecast>
    		<Entity>700</Entity>
    		<data>
    			<date>
    				<day>19</day>
    				<month>2</month>
    				<year>2021</year>
    			</date>
    			<period recID="7001">
    				<time>8:30</time>
    				<ItemSold>25</ItemSold>
    				<Price>120</Price>
    			</period>
    		</data>
    	</forecast>
    However, what I need is -

    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <DataImport xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    	<forecast>
    		<Entity>700</Entity>
    		<data>
    			<date>
    				<day>19</day>
    				<month>2</month>
    				<year>2021</year>
    			</date>
    			<period recID="7001">
    				<time>8:00</time>
    				<ItemSold>23</ItemSold>
    				<Price>119</Price>
    			</period>
    			<period recID="7001">
    				<time>8:30</time>
    				<ItemSold>25</ItemSold>
    				<Price>120</Price>
    			</period>
    		</data>
    	</forecast>
    	<forecast>
    		<Entity>701</Entity>
    		<data>
    			<date>
    				<day>19</day>
    				<month>2</month>
    				<year>2021</year>
    			</date>
    			<period recID="7002">
    				<time>8:00</time>
    				<ItemSold>23</ItemSold>
    				<Price>121</Price>
    			</period>
    		</data>
    	</forecast>
    </DataImport>
    Only one entry for each unique entity ID and one date entry for each unique date within each entity tag.
    Adding another sample file with few examples, hope it helps.
    Is there a way we can do this via VBA if not possible by just using XML mapping?
    Attached Files Attached Files
    Last edited by DocAElstein; 02-14-2021 at 11:59 PM. Reason: # [Code] your code goes here .. [/code]

Similar Threads

  1. Replies: 6
    Last Post: 09-24-2020, 10:36 AM
  2. XML Mapping in Excel Sheet
    By Ranjithkumar in forum Excel Help
    Replies: 1
    Last Post: 01-28-2014, 09:14 AM
  3. Xml Mapping in Excel Macro
    By dhivya.enjoy in forum Excel Help
    Replies: 1
    Last Post: 10-18-2013, 04:11 PM
  4. Convert selected file to XML and save.
    By dhivya.enjoy in forum Excel Help
    Replies: 7
    Last Post: 10-09-2013, 01:32 PM
  5. Replies: 0
    Last Post: 08-23-2012, 08:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •