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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to populate listview with remote xml data

Status
Not open for further replies.

Edward07

Programmer
Apr 13, 2007
49
NL
Hi all. i have the following remote rss xml in rss.php I want to populate the xml data to vb6 listview. could any one show me how this can be done.Thanks

Note:The number of items in xml is dynamic not fixed

rss.php
Code:
  <playlist>
  <song>
  <artist>artistname1</artist> 
  <name>artistname1</name> 
  <image>image1.gif</image> 
  <rating>2028574083</rating> 
  <songid>566</songid> 
  <totalvotes>09898</totalvotes> 
  </song>
    
  <song>
  <artist>artistname2</artist> 
  <name>artistname2</name> 
  <image>image2.gif</image> 
  <rating>2028574083</rating> 
  <songid>566</songid> 
  <totalvotes>09898</totalvotes> 
  </song>
...
  </playlist>
 
You can use some XML DOM component or an incremental parser like SAX or just code your own.

Be careful coding anything that relies too strongly on specific characteristics of the XML you're handling unless you generate it yourself. People using XML are liable to suddenly throw in extra elements or decide to use attributes (or new ones) and you need to parse with full generality and then ignore items you don't care about.

Also try to handle errors gracefully if rolling your own. Broken XML is far from rare in the wild.

Here's one old article XML and Visual Basic.

As an aside, it looks quaint the way VB6 was considered a "middle tier" language in 2000. I assume this was due to its role in creating ActiveX DLLs to help beef up the VBScript in ASP pages.

For a quick-and-dirty DOM tree when parsing small XML documents I tend to use a "node" class that contains two VB Collection objects and a String. The String holds the node name, one collection holds the node's attributes, and the other holds references to child node objects. You just add a few methods to do appendAttribute, appendChild, etc. I create these through a factory class that is my root node, and it has the additional createNode method.

In most cases you may as well just use the MSMXL library. See lots of articles like Parsing documents with the DOM in VB6.
 
I should add that once you have it all parsed into a DOM or (considering the fairly "flat" XML you show) even an unconnected ADO Recordset... populating some type of grid, list, or other control becomes easy enough.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top