Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel: how to extract data item from xml file

Status
Not open for further replies.

mssngr

Programmer
Jul 21, 2002
7
0
0
AU
Is there an easy way to extract particular data items from an xml file using VBA? I want two particular items which I know the tags for.
I would rather avoid loading the file as text and searching cells for the items in question, though if this is the simplest way I guess it'll have to do.
Do I have to write stuff to parse the file myself, or are there some short-cuts I can use?

Am developing in Excel 97 but destination is 2000. Relates to a distribution verification utility I am creating which interrogates logs that are in xml format.

thanks,
mssngr
 
Bear with me here as I walk through my thoughts...
I just recently wrote an XL macro to extract the Album, Artist, Song and Track number from a windows media player playlist file (.wpl). It has a similar format to an .XML format. But mine involves a line-by-line search for a specific string. If it finds it, then the macro loads the line, manipulates the string and enters the required text into the spreadsheet formated the way I want it.
That having been said, it would be easier than anything to do if the tags are on the same line... quite a big if!
If it were me - because I'm not sure of an easy way import XML data (although there should be and if not I'm sure thee will be soon) - I would line-by-line search for the beginning tag and then import all the lines between it and the closing tag, then import and manipulate that data. I'm not sure if that helps or not... sorry for the long-windedness (is that even a word?).

Hopefully there are easier ways. I'd like to know also.

********************
What's the best way to get the answers you need?? See FAQ222-2244 for details!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top