Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XML parsing from AppleScript (Kumar Shailove)



i'm surprised no one's mentioned tiger's built-in XML parsing...here's the code i use to parse tivo info files:

try
   set tivoFile to POSIX file tivoFile
   set tivoFile to tivoFile as Unicode text

   tell application "System Events"
      set theXML to contents of XML file tivoFile
         set tivo to XML element "TvBusMarshalledStruct:TvBusEnvelope" of theXML
            set startTime to value of XML element "startTime" of tivo
            set stopTime to value of XML element "stopTime" of tivo
            set showing to XML element "showing" of tivo
               set channel to value of XML element "displayMajorNumber" of ¬
                  XML element "channel" of showing
               set prog to XML element "program" of showing
                  set progTitle to value of XML element "title" of prog ¬
			& " #" & channel as string
                  set episodeTitle to ""
                  try --   optional entry
                     set episodeTitle to value of XML element "episodeTitle" ¬
			of prog
                  end try
                  set descr to ""
                  try --   optional entry
                     set descr to value of XML element "description" of prog
                  end try
   end tell
on error emsg
   display alert "parsing tivoXML: " & fileName & return & emsg
end try


_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/applescript-users/email@hidden Archives: http://lists.apple.com/mailman//archives/applescript-users

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.