Results 1 to 2 of 2

Thread: quick xml creation question

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2005
    Posts
    277

    quick xml creation question

    Hi all,
    I have a small simple program that will create an xml file from files contained in a folder mp3s actually.

    It works OK but I am trying to get rid of the .mp3 extension from the title. I need it in the filename the xml is created as below

    <?xml version="1.0"?>
    <songs>
    <song path="my_mp3s/ ANVIL_CHORUS.MP3" title="ANVIL_CHORUS.MP3">
    <song path="my_mp3s/ Black Hawk Down - Leave No Man Behind.mp3" title="Black Hawk Down - Leave No Man Behind.mp3">
    <song path="my_mp3s/ Im only sleeping#.mp3" title="Im only sleeping#.mp3">
    <song path="my_mp3s/ nowhere man.mp3" title="nowhere man.mp3">
    </songs>

    but i need to remove the .mp3 from the title like this
    <song path="my_mp3s/ nowhere man.mp3" title="nowhere man">

    VB Code:
    1. Private Sub Command2_Click()
    2.  
    3.  
    4.     Dim f1 As Integer, jpgurl As String, xmlpath As String, MyPath As String, songpath As String, slidenode As String, SongName As String, mp3path As String, f2 As Integer, i As Integer
    5.     Dim Artist As String, artname As String, fname As String
    6.     Dim mysong As String
    7.    
    8.     mp3path = "C:\Program Files\Mgamerz\my_mp3s\"
    9.     xmlpath = "C:\Program Files\Mgamerz\"
    10.  
    11.    
    12.    
    13.      f2 = FreeFile
    14.     Open mp3path & "mp3.txt" For Output As #f2       ' if you don't need mp3.txt take out
    15.      f1 = FreeFile
    16.      
    17.     Open mp3path & "slides.xml" For Output As #f1
    18.     Print #f1, "<?xml version=""1.0""?>"
    19.     Print #f1, "<songs>"
    20.     'Print #f1, "<pic>"
    21.     SongName = Dir(mp3path & "\*.mp3")   ' get first track
    22.     i = 1
    23.     While Not Len(SongName) = 0
    24.    
    25.    
    26.     MyPath = Right(mp3path, (Len(mp3path) - Len(xmlpath))) & " " & SongName
    27.  
    28.  
    29.        
    30.               MyPath = Replace(MyPath, "\", "/")
    31.  
    32.              
    33.  
    34.            MyPath = Replace(MyPath, "", "", 1, 1)
    35.       'songpath = "<song path=""" & MyPath & """  title=""" & SongName & """/> "
    36. songpath = "<song path=""" & MyPath & """ artist=""" & Artist & """ title=""" & SongName & """> "
    37.  
    38.        
    39.         Print #f1, songpath
    40.         Print #f2, SongName                  ' for mp3.txt
    41.         Sleep 100                                ' slight pause, needed
    42.         SongName = Dir                         ' get next track
    43.    
    44.     Wend
    45.    ' Print #f1, "</pic>"
    46.     Print #f1, "</songs>"
    47.  
    48.  
    49. Close
    50. End Sub

    Thanks in advance

  2. #2
    Fanatic Member modpluz's Avatar
    Join Date
    Sep 2005
    Location
    Lag, NG
    Posts
    633

    Re: quick xml creation question

    but i need to remove the .mp3 from the title like this
    <song path="my_mp3s/ nowhere man.mp3" title="nowhere man">
    if what you want to get rid of is the .mp3 in the title, then try this

    VB Code:
    1. <song path="nowhere man.mp3" title=" & replace("nowhere man.mp3", ".mp3", "") & ">

    i guess you already know how to do that
    Last edited by modpluz; Dec 23rd, 2005 at 08:09 PM.
    If you want the rabbit to hop, move the carrot - Paul Kellerman(Prison Break)

    onError GoTo http://vbforums.com



    My Bits:
    VB6: Change Column Name in MS ACCESS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width