VFPConversionLogo
HomeBlogLearnProductsEventsServicesAbout UsFAQ
Mike Yeager's Blog

Friday, June 23, 2006
The World Cup, Baby!
This morning, I skipped right past the so called "sports news", past the headlines of the the US's dismal showing in their bracket, even past Markus Egger's blog, which no doubt contains a new posting, a blow-by-blow account of the all-important Ivory Coast game he attended yesterday.  I went straight for the hard news, the in-dept coverage, the essence of the event.  Today, I went straight to "Babes of the World Cup" http://msn.foxsports.com/soccer/pgStory?contentId=5676192&pageNumber=1 and I was not disappointed.  Once again MSN and Fox Sports show the innovation and dedication they are famous for.  You have to love MSN...

Cheers,
Mike

Posted @ 8:45 AM by Yeager, Mike (myeager@eps-software.com) - Comments (3)


Thursday, June 01, 2006
Learning to do XML in .NET
I recently had the opportunity to learn something new.  Hard as that can be, I really enjoy it and appreciate getting the opportunity.  This time around , it was learning how to read, edit and write XML in .NET.  Armed with the help docs, a couple of books and Google, I set out...

From what I can tell, Microsoft's first attempt at this technology needed a major overhaul, which it got in 2.0.  That left a lot of confusing legacy support and added a lot of new options making things pretty murky.  The initial learning curve is pretty big and I was asking myself, "Where to start"?  In order to read XML in code, you have a few things you need to learn about and a few choices to make. You start by choosing from one of the following:  XmlReader, XmlTextReader, XmlValidatingReader. XmlDocument, XPathDocument, and I think there are a couple of other choices.  When writing XML, you choose from a corresponding list of classes for writing.  After you pick one, you can learn about options such as XmlReaderSettings which lets you configure the XmlReader for example, and companion classes such as the XPathNavigator which you use in conjunction with some of the reader classes to navigate around them and in some cases write XML.   Beyond that there are classes like XmlResolver and XmlNamespaceManager that you'll have to wrestle with if you want to do any serious work with XML.

After many hours of plowing through documentation, books, blogs and even an astrological chart or two, I was starting to make sense of it all and I was really coming to appreciate the power of the tools if not the user manuals <g>.  It would take a while to sort out the "right" way to work with XML in different circumstances, but I was off and running... ready to code...

When it came to coding, I found myself going back to the docs incessantly.  Even when I picked the right way to go about things, implementing was painful.  Some of it stemed from horrible documentation, some from the major changes from 1.1 to 2.0.  For instance, in 1.1 the XmlReader was supposed to be an abstract class and you generally used an XmlTextReader, a concrete implementation of XmlReader to read XML like this:

XmlTextReader xtr = new XmlTextReader("myfile.xml");

In 2.0, they decided that having a bunch of different concrete implementations for different purposes wasn't such a hot idea, so they did a major overhaul on the XmlReader and now everyone recommends using that.  In other words, in 1.1 "use XmlTextReader, not XmlReader", in 2.0, just the opposite.  Also, you use a different syntax for XmlReader in 2.0:

XmlReader xr = XmlReader.Create("myfile.xml");

Sometimes I wonder if I should go back to using a StringBuilder!  I certainly would have had this project wrapped up a lot sooner.  In the long run however, this is good stuff to know.  Where to start?  Well, unfortunately, it depends on the problem you're trying to attack and your approach will have to change with the situation.  My advice for very large XML documents and blistering forward-only style processing is to look at XmlReader (and XmlWriter).  For small to reasonably sized documents and when speed isn't your paramont consideration, look at XmlDocument which reads the whole thing into memory so that you can work on it at any random place in the doc that you choose and then move to some other random place.   Once you figure that out look at XPathNavigator for moving around to those random places more easily.  It's a starting point and you can branch out from there as you learn the technologies.

I wonder what new thing I'll get to learn next? ? ? ? ?

Posted @ 6:05 PM by Yeager, Mike (myeager@eps-software.com) - Comments (23)


Blog List
VFPConversion Blog
Markus Egger's Blog
Ken Levy's Blog
Claudio Lassala's Blog
Blog Archive
March, 2008 (1)
February, 2008 (1)
October, 2007 (1)
September, 2007 (2)
July, 2007 (1)
May, 2007 (3)
March, 2007 (3)
January, 2007 (2)
December, 2006 (1)
October, 2006 (2)
September, 2006 (2)
August, 2006 (6)
July, 2006 (3)
June, 2006 (2)
May, 2006 (4)