Skip to main content

C# : check whether input string data is XML or NOT



To check whether input string data is XML or NOT.


Simply copy and paste the following code. This code will throw an exception in case input string is not XML.

       if (!String.IsNullOrEmpty(sXMLMessage))
            {
                try
                {
                    System.Xml.Linq.XElement.Parse(sXMLMessage);
                   // Business Logic for XML string data here

                }
                catch (XmlException ex)
                {                  
                   // Business Logic for non-xml string data here
                }
            }

Comments

Popular posts from this blog

Deploying Custom Pipeline Component on BizTalk Server (PROD)

Deploying Custom Pipeline Component on BizTalk Server: ·         Deploying BizTalk Custom Pipeline Component   on BizTalk Server 2006 or Older Version : To deploy the custom Pipeline component on BizTalk server 2006 or older version. We need to add the Custom Pipeline component in GAC as well as “ C:\Program Files (x86)\Microsoft BizTalk Server 2006\Pipeline Components ” folder.   At design time it will access the Pipeline component dll located in “….. Microsoft   BizTalk Server 2006\Pipeline Components ” folder and show the component in pipeline toolbox. At runtime the BizTalk will use the Custom Pipeline component from GAC. ·         Deploying BizTalk Custom Pipeline Component   on BizTalk Server 2006 R2 or New Version : To deploy the custom Pipeline component on BizTalk server 2006 R2 or later version. We need to add the Custom Pipeline component only in “C:\Pr...

BizTalk WCF : BizTalk System.ServiceModel.AddressAccessDeniedException

BizTalk System.ServiceModel.AddressAccessDeniedException You configure a self-hosted service at a BizTalk receive location using a localhost address, and when you try to enable the service (receive location) you get the above error with the details 'HTTP could not register URL http://+:80/Service.CreateService.FirstService.v1/. Your process does not have access rights to this namespace' I was getting above error when trying to Enable WCF receive location. To overcome this issue, you need to Solution 1. Open the Visual studio command prompt (using the run as administrator option) 2. Type in the command netsh http add urlacl url=http://+:80/<the rest of the address that comes after localhost/> user=DOMAIN\username (So, if your full address ishttp://localhost/company.bookings.carbookingservice, you type inhttp://+:80/company.bookings.carbookingservice) User Name should be same under which your host is running. 3. Enter to run the command 4.  res...

Object Oriented Programming Concepts

OOP Basics Visual Basic was Object-Based, Visual Basic .NET is Object-Oriented , which means that it's a true Object-Oriented Programming Language . Visual Basic .NET supports all the key OOP features like Polymorphism , Inheritance , Abstraction and Encapsulation. It's worth having a brief overview of OOP before starting OOP with VB. Why Object Oriented approach? A major factor in the invention of Object-Oriented approach is to remove some of the flaws encountered with the procedural approach. In OOP, data is treated as a critical element and does not allow it to flow freely. It bounds data closely to the functions that operate on it and protects it from accidental modification from outside functions. OOP allows decomposition of a problem into a number of entities called objects and then builds data and functions around these objects. A major advantage of OOP is code reusability. Some important features of Object Oriented programming are as follows: Emphasis ...