mIRC Homepage
Posted By: MeStinkBAD XML parser.... - 14/03/04 01:16 AM
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....
Posted By: Online Re: XML parser.... - 14/03/04 02:44 AM
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
Posted By: Soul_Eater Re: XML parser.... - 25/03/04 07:08 AM
i was gonna say there is an XML parsing DLL
© mIRC Discussion Forums