mIRC Home    About    Download    Register    News    Help

Print Thread
#75142 14/03/04 01:16 AM
Joined: Apr 2003
Posts: 342
M
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Apr 2003
Posts: 342
I'm trying to write an XML parser for mIRC to parse an iTunes library file (for the moment, I'll eventually move on to custom XML files). So far I've have limited sucess. I was wondering if anyone out there could help me out... perhaps a COM entry exists (though I don't care for COM objects). Here is the code I have so far. It's a little buggy.

Code:
alias READXML {
  var %fref = LIB
  var %string, %token, %value
  var %c

  ;-- predefined tags
  hadd -m PLAYLIST.TOKENS n0 Track ID
  hadd -m PLAYLIST.TOKENS n1 Name
  hadd -m PLAYLIST.TOKENS n2 Artist
  hadd -m PLAYLIST.TOKENS n3 Composer
  hadd -m PLAYLIST.TOKENS n4 Album
  hadd -m PLAYLIST.TOKENS n5 Genre
  hadd -m PLAYLIST.TOKENS n6 Kind
  hadd -m PLAYLIST.TOKENS n7 Size
  hadd -m PLAYLIST.TOKENS n8 Total Time
  hadd -m PLAYLIST.TOKENS n9 Track Number
  hadd -m PLAYLIST.TOKENS n10 Year
  hadd -m PLAYLIST.TOKENS n11 Date Modified
  hadd -m PLAYLIST.TOKENS n12 Date Added
  hadd -m PLAYLIST.TOKENS n13 Bit Rate
  hadd -m PLAYLIST.TOKENS n14 Sample Rate
  hadd -m PLAYLIST.TOKENS n15 Normalization
  hadd -m PLAYLIST.TOKENS n16 Location
  hadd -m PLAYLIST.TOKENS n17 File Folder Count
  hadd -m PLAYLIST.TOKENS n18 Library Folder Count
  hadd -m PLAYLIST.TOKENS n19 Play Count
  hadd -m PLAYLIST.TOKENS n20 Play Date
  hadd -m PLAYLIST.TOKENS n21 Play Date UTC
  hadd -m PLAYLIST.TOKENS n22 Equalizer
  hadd -m PLAYLIST.TOKENS n23 Rating

  /.fopen %fref "iTunes Library.xml"

  while (1) {
    /.fseek -w %fref *<dict>
    if ($feof || $ferr) { break }
    var %space = $false
    while ($fgetc(%fref)) {
      %c = $ifmatch
      if (%c == 32) { %space = $true | continue }
      %c = $chr(%c)
      if (%c !isin <>) && (%c != $t) {
        ;-- space hack fix
        if %space { %string = %string %c | %space = $false }
        else { %string = %string $+ %c }
      }
      if (%c == <) {
        if ($hfind(PLAYLIST.TOKENS,%string,1).data) {
          %token = %string
        }
        else {
          if (%string != $null) && (%string != $chr(32)) {
            %token = %token = %string
            
            ;-- write out to a file
            write XML.TXT %token
            %token = $null
          }
          %string = $null
        }
      }
      if (%c == >) { 
        %string = $null
      }
    }
  }
  /.hfree PLAYLIST.TOKENS
  /.fclose %fref
}


I don't know if anyone can really help me. Any assistance would be helpful. Thanks....


Beware of MeStinkBAD! He knows more than he actually does!
#75143 14/03/04 02:44 AM
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
I didn't look at your code yet, but you might want to see others' work before you start your own...
http://www.mircscripts.org/archive.php?s...;amp;perpage=20

#75144 25/03/04 07:08 AM
Joined: Mar 2003
Posts: 187
S
Vogon poet
Offline
Vogon poet
S
Joined: Mar 2003
Posts: 187
i was gonna say there is an XML parsing DLL


Link Copied to Clipboard