Xml and .net

This sums up how I feel about this subject:

You are the butt end of a very very sick joke. – D.K

I don’t have any words of encouragement.  Things that should be very basic to do are not.  I made the mistake of wanting to read in a xhtml formatted document as an XmlTextReader.  That didn’t fly at all.  Googling around and searching the interwebs didn’t leave me with much encouragement either.  The rub seems to be that the DTD validator doesn’t appear to work very well.  I thought it could be the document itself, but it’s well formatted and doesn’t bark when I ran it through the external validator.  I tried to change the settings on the reader so that it didn’t go crazy…. that didn’t work either.  Even if it did work, the DTD is loaded externally from the w3 site.  So the solutions I have seen to work around this pull in the DTD as a local resource instead and add a resource manager to support pulling it in instead of the remote version.

Silverlight has some built in tools (System.Xml.Utils) to parse xhtml as a known doc type… but you cannot use it unless you gut out almost all of your project and use silverlight’s custom mscorlib and xml.  That isn’t a reasonable solution.  I even went as far as reflecting into the library and pulling the code into it’s own project to test it… no dice.

So far, I am stumped.  If I pull in the file as an XmlDoc and iterate through the nodes, t hat seems to work fine for now.  However, this isn’t very efficient either.  Ideally I want that bad boy as a stream so I can parse it into the end code as I am reading the stream.  Yet so far, I have just run into gotchas.  Everyone I have talked to has basically said the same thing… Xml and .NET do not work very well.

I even took some time to look at the SAX.net project.  This seems to be a better approach… but the project is rather old and the documentation kinda stinks.  The sax parser is implemented externally, so in order to consume it you have to pass in an assembly reference to the project to find and create the sax parser.  It’s kinda weird.

This (Xml and .Net) is going to be my first thing to work on with the nkeiko project.  It’s quite depressing to be thrown a task and fail at something that on the surface seems easy.  But, these are the things we should jump into, not run away from.

That is all.

-A

Advertisements
Post a comment or leave a trackback: Trackback URL.

Comments

  • Dave Milner  On March 11, 2009 at 4:01 pm

    Just a suggestion – look into the LINQ to XML feature set.

    Dave

    • pinvoke  On March 12, 2009 at 1:14 am

      I have looked at Linq to XML already, however for this task I specifically want to tap into the stream itself for performance reasons. I am being rather head strong about it though… I might end up use an XDocument and do a transform with a query instead… it’s just not as fast.

      -A

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: