[Tutor] Simple XML parsing

Tim Wilson wilson at visi.com
Fri Dec 16 07:18:29 CET 2005


Hi everyone,

I've got a little project that requires me to parse a simple XML  
file. The file comes from the browser history of Apple's Safari and  
includes the URL that was visited, the title of the Web page, the  
date and time it was last visited, and the total number of times it  
was visited. Here's a snippet:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http:// 
www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
   <key>WebHistoryDates</key>
   <array>
     <dict>
       <key></key>
      <string>http://www.hopkins.k12.mn.us/pages/eisenhower/ 
eisenhower.lasso</string>
       <key>displayTitle</key>
       <string>Welcome to Eisenhower Elementary</string>
       <key>lastVisitedDate</key>
       <string>156350702.0</string>
       <key>title</key>
       <string>Welcome to Eisenhower Elementary</string>
       <key>visitCount</key>
       <integer>285</integer>
     </dict>
   </array>
   <key>WebHistoryFileVersion</key>
   <integer>1</integer>
</dict>
</plist>

Let's say that instead of one <dict>, the xml file had 100 of them. I  
want to generate a simple table of URLs and the dates they were last  
visited. I can handle everything except parsing the XML file and  
extracting the information.

Anyone have any pointers?

-Tim

-- 
Tim Wilson
Twin Cities, Minnesota, USA
Educational technology guy, Linux and OS X fan, Grad. student, Daddy
mailto: wilson at visi.com   aim: tis270   blog: http://technosavvy.org



More information about the Tutor mailing list