XML Format Issue

heffo500

New Member
Joined
Sep 28, 2016
Messages
44
Hi

I have an excel macro that is creating an XML but it saving the XML file like this:

HTML:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<funds xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <fund>
  <id>123456</id>
  <name>Apple</name>
  <basis>F</basis>
  <type>Fruit</type>
  <valdate>11-07-2019</valdate>
  <creationdatetime>11-07-2019 16:34:44</creationdatetime>
However I want it like this:

HTML:
<?xml version="1.0" encoding="utf-8"?><funds xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><fund><id>[LEFT][COLOR=#222222][FONT=Verdana]123456[/FONT][/COLOR][/LEFT]</id><name>[LEFT][COLOR=#222222][FONT=Verdana]Apple[/FONT][/COLOR][/LEFT]</name><[LEFT][COLOR=#222222][FONT=Verdana]basis[/FONT][/COLOR][/LEFT]>F</[LEFT][COLOR=#222222][FONT=Verdana]basis[/FONT][/COLOR][/LEFT]><type>[LEFT][COLOR=#222222][FONT=Verdana]Fruit[/FONT][/COLOR][/LEFT]</type><valdate>10-07-2019</valdate><creationdatetime>10-07-2019 13:50:42</creationdatetime>

This is the macro:
Code:
Sub Macro1()
    '
' Macro1 Macro
'
Application.DisplayAlerts = False

Macrofile = ActiveWorkbook.Name
Range("Q4").Select
File_Name = ActiveCell
'
    
    Range("A2:F96").Select
    
    Workbooks.OpenXML Filename:= _
        "G:\Destop\Sample.xml" _
        , LoadOption:=xlXmlLoadImportToList
    XML_Upload = ActiveWorkbook.Name
    
    Windows("XML creator.xls").Activate
    Selection.Copy
    Windows(XML_Upload).Activate
    Range("A2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    ActiveWorkbook.SaveAsXMLData Filename:= _
        File_Name _
        , Map:=ActiveWorkbook.XmlMaps("xml_Map")
    ActiveWindow.Close
    Sheets("TEST").Select
    
    Message = MsgBox("Done", vbOKOnly, "")
    
End Sub
Any one have any ideas how?
 
Last edited by a moderator:

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Im trying to get the XML to read in one continous line rather than having the spacing, not sure how to resolve this
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,739
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top