1

I'm trying to store content scraped from several lyric and chord websites into separate variables into either a multi-dimensional array, or into separate string arrays, but I've been stuck trying some different approaches. I've searched through the site and have found many questions that were similar, though incompatible or difficult to adapt with my project.

If content was stored in a multi-dimensional array, it would look like this:

Search Site > Artist > Link to artist page > Song > Link to song page > Tab types (Chords, Lyrics, Tabs) > Link to tab type (Chords, Lyrics, Tabs) > Content

A good visual representation of this array would look like this:

enter image description here

Keep in mind the content is dynamic, so it is not possible for me to hard-code array bounds without first retrieving the size of the content I'm storing (e.g. amount of songs per artist)

Below are the approaches I've tried and their shortcomings, or where I failed to implement correctly:

Multi-dimensional (jagged) arrays required explicit bounds, and only the rightmost array can be resized. (This approach can be made to work by setting explicit bounds after all content has been captured, but creating temporary variables and passing them all to the multi-dimensional array requires a lot of code and seems like a "dirty" solution to my problem.)

Tuples seemed promising, but for some reason, I was not able to create a tuple containing different variable types, or the approach was confusing.

Individual arrays did not give me enough flexibility and required creating multiple new arrays dynamically. (e.g. an array for the list of songs for a specific artist, another for the tab links in a specific song, etc.)

I'm sure I've tried others, but I cannot remember at the moment, I've seen a similar approach done with Structures on a sample for a user control here and others who implemented a local database to contain all the elements.

All that is needed is an approach that is simplistic but functional.

Any help is gladly appreciated.

Another representation here:

representation

5

Seems as if your main difficulty is that you're using arrays instead of lists. Lists do not have the problem of requiring an initial size; you can grow them or shrink them as needed.

I also have the impression that you think you have to store the entire content of the web site in a single data structure. You don't; a relational database like SQL Server would suffice. Artists, songs and song content would each go into its own table in the database.

Assuming that what you're really after is a ViewModel, it would look something like this:

Public Class ArtistSongViewModel
    Public Property Artist() As Artist
        Get
            Return m_Artist
        End Get
        Set
            m_Artist = Value
        End Set
    End Property
    Private m_Artist As Artist
    Public Property Hyperlink() As String
        Get
            Return m_Hyperlink
        End Get
        Set
            m_Hyperlink = Value
        End Set
    End Property
    Private m_Hyperlink As String
    Public Property Songs() As List(Of Song)
        Get
            Return m_Songs
        End Get
        Set
            m_Songs = Value
        End Set
    End Property
    Private m_Songs As List(Of Song)
End Class

Public Class Song
    Public Property Name() As String
        Get
            Return m_Name
        End Get
        Set
            m_Name = Value
        End Set
    End Property
    Private m_Name As String
    Public Property Hyperlink() As String
        Get
            Return m_Hyperlink
        End Get
        Set
            m_Hyperlink = Value
        End Set
    End Property
    Private m_Hyperlink As String
    Public Property Content() As List(Of SongContent)
        Get
            Return m_Content
        End Get
        Set
            m_Content = Value
        End Set
    End Property
    Private m_Content As List(Of SongContent)
End Class

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.