obive.net

Friday February 11 2005 @ 12:56 AM

I have just spent the past few hours attempting to deserialize an iTunes Library XML file into .NET. I have been unsuccessful. I can?t see how people accept XML, it?s so miserable! UGH! All this DTD, XSD, XMLSerializer, .NET, XMLSpy, its making me sick. If I cant get this working, I?m going to have to do all this crap manually, and how much is that going to suck? I use .NET?s XmlTextReader which seems to be based on DOM for retreving the music folder?s location:

	Dim xmlFilePath As String = Environment.GetFolderPath(Environment.SpecialFolder.Personal) _
		 + "\My Music\iTunes\iTunes Music Library.xml"
	With New Xml.XmlTextReader(New StreamReader(xmlFilePath))
		Do .Read() Loop Until .Value = "Music Folder"
		Do .Read() Loop Until .Name = "string"
		.Read()
		Return .Value
	End With

That just LOOKS fragile. At least it?s not ugly. I can?t see using this method to parse the entire file. Now whats cool about all this XML stuff is that when the parser starts parsing the file it reads:

	

Of coarse the parser needs to go out to apple.com and download this great file. So this now requires an internet connection just to parse the file. And this isn?t even the XmlValidatingReader! You know I was surprised when, while it was parsing the file, it throws a System.Net.WebException at me. So if a user isn?t connected to the internet, they?re greeted with this:

	Error reading library XML file. Possible cause: 
	Can't contact apple.com to get XML definition.
	Check your internet connection.

I?m starting to think I?m doing this all wrong. For a ?simple standard? designed for interoperability, XML sure is a harsh mistress.

Our internet host is starting to irk me... They still haven?t fixed the problem where the server cant resolve anaka.obive.net =)