XML Tidbits

by Chris 4/1/2008 12:00:26 PM

Okay I never professed to being a developer.  I just like to dab in code and try to mimic the best practices I see out in the development community.  That being said sometimes I am unable to find samples of what I am trying to accomplish.  This was the case when I started writing the ConvertExtensions console application.  So I figured it was worth mentioning it on my blog for the next poor soul who is trying to do something similar to what I am doing.

XMLlogo The pain was around reading the attribute of a XMLNode.  This is probably second nature to a seasoned developer but for me it took several hours of searching to find the following code:

XMLDocument.SelectSingleNode(XMLNode[@AttributeName='"AttributeValue]");

So let me explain.  The extensions.xml file has a XMLNode that looks like the following:

<ManagedExtension Name="BBCode">

Well it turns out that the value for ManagedExtension XMLNode is not BBCCode.  The Name field is an attribute that has its own value.  So to access this information you have to add the [attributeName=attributeValue] field to the call.  Duh...  Took forever to find sample code to do this.

If you want to see exactly how this looks in real life code then download the source code for the ConvertExtensions application and you can see how I used it to find all of the extension XMLNodes.

Add comment


(Will show your Gravatar icon)  

biuquote
  • Comment
  • Preview
Loading




Powered by BlogEngine.NET Theme by Mads Kristensen Hosted by 1and1 Hosting Sign in
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way. © 2008 Chris Blankenship

DSCODUC on Technorati  

Stop Spam Harvesters, Join Project Honey Pot   This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License  

Welcome to my blog

Welcome to my site

Villainy wears many masks,
none of which so dangerous as virtue…



LinkedIn   GeoURL

Recent Comments

Comment RSS

Wordle Gallery

Shelfari Book Library