some interesting responses on UTF-16 problem with XMLTextWriter

 This is what hb replied with : yar may be, becauseutf-16 is two byte per character.so with string writer its unicode.if u enforece ascii then utf-8 would be there.(note: my reply is just an argument, i might need correction, so dont hesitate to correct me)—hBI replied hb’s mail as following: yes exactly thats wat the point is.. it sounds reasonable for string writer to generate a utf-16 prologues .. but my amazement revolves around the fact there isnt any support for parametrizing prologue specually encoding specs..This is what Ahsan had to add: There is one thing that i think you … Continue reading some interesting responses on UTF-16 problem with XMLTextWriter

System.IO.StringWriter and UTF-16 Encoding problem with System.XML.XMLDocument

 I am continuing my work with System.XML and System.XML.XPath namespaces. This implies that my adventure with XML and .NET is not over yet. I came across this interesting situation while freezing my code for next release.I was actually generating XML document using System.IO.StringWriter and System.XML.XMLDocument. Apparently there shouldnt be any issues with it. But actually there is a small problem with that. When you use StringWriter to write XMLDocuments it appends a prologue with “UTF-16” encoding specified. Now theres a big problem if you want to change the encoding to “UTF-8” or any thing else (available in System.Text.Encoding). You cant … Continue reading System.IO.StringWriter and UTF-16 Encoding problem with System.XML.XMLDocument

Extracting XMLNode from XPathNodeIterator

The project that I am working on these days require me to play a lot with XML. To navigate XML and fetch required information I use XPath to query XML. Though XPath offers significant performance gains over XMLNode (DOM) based parsing. However, there are times when you just want to use XMLNode perhaps you want to get hold of OuterXML or  want to append certain element to DocumentElement of XML document. In these scenarios XPathNodeIterator apparently is of no particular help, or so I thought atleast. I was actually iterating an XML document using XPathNodeIterator and wanted to fetch the … Continue reading Extracting XMLNode from XPathNodeIterator

System.Enum.Parse :: The right way!

To compare strings with enums the right way, one should use enum.parse rather than comparing string literals. Following is an example where i am parsing a string type variable named messageId and creating an enum of type MessageTypeMessageType messageType = (MessageType) System.Enum.Parse(typeof(MessageType),messageId,true);Last argument in System.Enum.Parse specifies if the enumeration/comparison should be case sensitive or not.

XPath Query

I came across following good links that you may find useful if you want to learn the art and science of XPath query.1- Understanding XPath at Queue Publishing2- XPath Essentials at DNJ Online3- XPath Queries at Developer.com

Visualise XPath Queries with Visual XPath

Any one who has used XPath to navigate XML Documents knows that it is a tricky business to do. Selecting specified node(s), evaluating expressions and things like that could actually take a bit of your time. And this all isnt much intuitive to a common developr.I my self usually have to refer to XPath query syntax whenever i intend to use it. I came across this awesome tool that was written by my senior and mentor Noman Laghari.The best part with Visual XPath is that you dont really have to compile and execute your code just check if you wrote … Continue reading Visualise XPath Queries with Visual XPath

Undserstanding Microsoft Integration Technologies

In todays world of EAI (Enterprise Application Integration) and SO (Service Orientation) its very important to understand integrating technologies and tools that are made available to us. I always say that todays is the information world that can be thought of applications as an islands automated within themselves but not usually connected to others. And to connect them is “the task“. Sooner or later our most of efforts and development time would be consumed in either integrating applications or architecting/developing applications in such a way that they are easily “connectable“.Microsoft has provided us with a number of options for architecting/designing/developing … Continue reading Undserstanding Microsoft Integration Technologies