Wednesday, June 16, 2004

Cloning and Inserting an XML Node with C#

I've recently had some trouble locating some code to append data to an XML file. Just in case someone else out there is having the same problem, here is some code to assist.


//Instantiate an XML Document and load the file

XmlDocument objDoc = new XmlDocument();

objDoc.Load(Server.MapPath("/") + "/files/myxmlfile.xml");


//Set a root node pointer

XmlNode objRoot = objDoc.DocumentElement;


//locate the node you want to clone and copy it to a new node

string strXmlQuery = "/myNodePath/myNode";

XmlNode objToBeCloned = objRoot.SelectSingleNode(strXmlQuery);

XmlNode objNewNode = objToBeCloned.CloneNode(true);

//The bool value indicates true to copy the whole tree of chile nodes, false only copies the top node


//Alter the node and child nodes as relevant

objNewNode.InnerText = "alter node text or child node text and/or attributes as needed";


//Insert the node after the last child of a commoon parent (see note below)

objRoot.InsertAfter(objNewNode, objRoot.LastChild);


//Resave the xml file

objFilters.Save(Server.MapPath("/") + "/files/myxmlfile.xml");


NOTE: it is critical that the InsertAfter call is made from the common parent for the nodes. I initially tried using objDoc and it failed with "The referenced node is not a child of this node." One last thing, the SelectSingleNode call uses XPath to locate the node.


Well, I hope this helps someone else. There are some areas that may be improved, but this works and made sense in the scheme of the application I was writing.

Monday, June 14, 2004

Skype

Recently, myself and a few business partners started using the Skype beta (v0.98). I tried using the beta a year or so ago, but it was a failed attempt. Since then, the application itself has seen some improvement (if my memory serves me correctly).


Once SkypeOut is launched (PC to POTS), I hope the company is able to find a way to make money. I mention that fact since I actually like the application. Skype has done well in creating a reliable and quality VoIP solution and I would hate to see an application I like go by the wayside due to lack of income.


The other interesting service will be SkypeIn. This service will allow for POTS to connect to Skype users. This process is much more complicated, but I believe they will eventually find a way to do accomplish this task. Once done, I could see dumping my phone line. I would be very interested in seeing how this service would work for conference calls. Combining SkypeIn and SkypeOut, you could conference people all over the world at a low rate (or no rate if they are on their PC). It never hurts to mention that there will probably be a country limit with Skype.


The only trouble we experienced was due to a person's flaky internet connection. Granted we all have broadband in one form or another, I am interested to see how this service works when one of us is in Europe (more than likely a trip in August).


As always, I have one criticism of the application...lack of Instant Messaging (IM) features. It does have a little IM capable portion, but it doesn't work well when you are in a conference environment. Simply put, I can't get by without the ability to share text and files (screen sharing is nice too, but another bandwidth constraint). Granted I can solve this problem by using other applications (MSN IM, AIM, or YahooIM), I would prefer a single integrated (or partnered) environment. So if Skype added a premium feature set for a monthly or yearly charge, I would buy in a second (as long as they kept a well positioned price point).


In summary, nice application and you can't beat the price. Whether you are trying to contact family, have a small conference call (10 person limit with Skype), or keep in contact with friends, this is a great solution. So, grab a headset and start gabbing.

Wednesday, June 09, 2004

GMail Beta

Well, I finally opened a GMail account so I could play around with the features and see how it compares to the other email providers out there. As with anything, I have found good, bad, and ugly.


The feature set is decent, the interface is clean, and I do really respect the effort of reorganizing email in order to make it more consumable. I'm not sure if it will succeed, but only time will tell on that part. After my initial investigation, I think the new approach to conversations (like a message board) are handy.


However, I have found one missing feature that will keep me from migrating my Yahoo or Hotmail accounts to GMail. The management of contacts has regressed considerably when compared to tools that already exist. What do I mean by that? Just try to create a list of contacts. That's pretty basic functionality, but I didn't see a way to do it. Also, the only information regarding contacts that you can store is their first, last, and email address. What does this mean? You have to have two places to keep contact information (Gmail for email and another for address/birthday/etc.). I have enough problems keeping my contacts together without this limitation.


Another area that Gmail needs to improve is integration with IM and other types of collaboration. To think that email stands alone is a poor assumption. Granted I haven't read Gmail's intended growth path or claim to know what version one will contain, they need to think larger than email. Since Google doesn't have an IM client, what about expanding it to become an RSS reader?


One last area I would like to see improvement is in the interface. Granted Google has gotten by for years with the clean search interface, I don't want to spend time in email looking at the plain screen. Give me a skin or two to choose from. If they are ugly, at least I'll choose to go with the plain than have that be the only option.


Although the 1,000 mg of disk space is extremely attractive, it still isn't enough to over come the lack of contact management. If it added in contact management and the ability to integrate with other collaboration tools (RSS Reader, etc.), it would be a no brainer for me to switch. Also, if they were to throw in some sugar coating and make the interface more consumable, I would turn my back on Yahoo and Hotmail and tout the greatness of Gmail.

Wednesday, June 02, 2004

LAMP or No LAMP

Lately I have been pondering the likelihood of moving to a LAMP environment. The problem stems from this: my background and infrastructure is nearly all Microsoft technologies. I am quite interested in (and have even dabbled in) PHP and MySQL. The problem is that I very much enjoy the .NET environment over PHP. Assuming that my desire holds out, I will more than likely end up with a mixed mode environment. Over the next year, I will be moving all web access components (currently in ASP which I don't like more than PHP) to web services. These services will start in .NET and quite possibly stay that way (unless a compelling reason to change comes along). My biggest win is that I can keep my data in its original holding place (MS SQL, Exchange, etc.) and only expose that data to specific web servers. Those web servers can be running anything since their responsibility has now shrunk to a web service call and displaying the data. Ok, there needs to be some additional mention of client side scripting (which will continue to be javascript), but that will be fairly minimal.



Hopefully this will give me the most options, my preferred development environment, and not lock me completely in Microsoft. Granted most of my infrastructure applications will still be Microsoft, even those can now be replaced as necessary and only the web service need be updated.