Excel VBA to convert XML file from string to line by line

MichaelRSnow

Active Member
Joined
Aug 3, 2010
Messages
409
Hi

Does anyone know if VBA can read an XML text string and every time it hits a less than symbol "<" to moves it down a line (carriage return)

I know I can get a XML line by line converter via Notepad++, which is great but I'm trying to remove this step from a process when converting some data in the xml.

Pulling my hair out looking for a solution?

Thank you

for example
<Detail_Collection><Detail textbox4="No Change" textbox8="122559" /><Detail textbox4="No Change" textbox8="122560" />

would become
<Detail_Collection>
<Detail textbox4="No Change" textbox8="122559" />
<Detail textbox4="No Change" textbox8="122560" />
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
You can use "MSXML2.DOMDocument" object to read the data in the XML source.

If its on the net and if you can give the URL, I can help.
 
Upvote 0
You can use "MSXML2.DOMDocument" object to read the data in the XML source.

If its on the net and if you can give the URL, I can help.

The XML file is on my local drive (not the net) and the hope was to have VBA (via Excel) open and complete carriage return before each < symbol,

example string is shown below
HTML:
<Detail_Collection><Detail textbox4="No Change" textbox8="122559" /><Detail textbox4="No Change" textbox8="122560" />
 
Last edited:
Upvote 0
Without seeing the whole XML document, its hard to answer your question.

If you wish, you can PM me to send the XML file to me. Then, I can try to make my best...
 
Upvote 0
You can use "Google Drive" or a similar site to upload your file and give the download link, here.
 
Upvote 0

Forum statistics

Threads
1,224,821
Messages
6,181,163
Members
453,021
Latest member
Justyna P

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