Extract certain data from text file into excel using Macro

ADGJL

New Member
Joined
Jun 5, 2015
Messages
2
Hi All,

I have a text file from which I want to extract data which is under <Placemark> <name> node. For Example,
<Placemark> <name>abc</name></Placemark>
There are multiple <Placemark> <name> nodes, so I want the macro to search for all and extract every element under that node into excel sheet under column name "name".
Elements under <name> node is a combination of alphabets, special characters & numbers and the length of element varies.
It would be very kind if someone gives a try to write a macro for this.

Thanks in Advance!!

Anmola
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Can you post some sample data, so we can see what your working with?
Hi Ron,
The txt file data I'm working with is somewhat like
HTML:
  		<Placemark>			<name>path</name>			<Style>				<LineStyle>					<color>ffffffff</color>				</LineStyle>			</Style>			<LineString>				<tessellate>1</tessellate>				<coordinates>					-87.7,25.7,30 -88.40000000000001,26.3,30 -89.40000000000001,28,30 -89.8,30,30 -89.3,32.3,30 -86,37.5,30 -79,42,30 -70,47,30 				</coordinates>			</LineString>		</Placemark>		<Folder>			<name>wind swath</name>			<Snippet maxLines="2">composite of wind ranges throughout a 72-hr forecast period</Snippet>			<Icon>				<href>files/HMpalette_07.png</href>			</Icon>			<Placemark>				<name>winds >64kt(74mph)</name>				<Style>					<LineStyle>						<color>ff0000ff</color>						<width>1.5</width>					</LineStyle>
I want to extract name tag data which is under Placemark tag and Ignore the name tag data which is under Folder tag

</div>



</placemark><style>
<LineStyle>
<color>ffffffff</color>
</LineStyle>
</style><style>
<LineStyle>
<color>ff0000ff</color>
<width>1.5</width>
</LineStyle>


<color>bf0000ff</color>
</PolyStyle>
</style>
 
Last edited:
Upvote 0

Forum statistics

Threads
1,203,065
Messages
6,053,327
Members
444,653
Latest member
Curdood

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