How to distinguish whether the data from database text field is an XML or Text file ?

Posted on 2005-03-31
Medium Priority
Last Modified: 2010-04-23


I have a column in  SQL-Server 2000 database as (Text) field. I can store any type of file (Possibilly two Text & XML). Now with VB.NET code, i want to know whether the data is XML file or Text file !!

Can you suggest me the way to do it ?

Question by:kishore_peddi
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment

Accepted Solution

wyoung76 earned 1000 total points
ID: 13677606
Assuming that it's text XML, then my suggestion is to run an XML validation on the field to test for "XML-ness" or not.  This could be as naive as doing:

    Dim xd As System.Xml.XmlDocument
        ' succeeds if it's validating XML
        xd = New System.Xml.XmlDocument.LoadXml(loadedText)
    Catch e As XmlException
        ' it isn't validating XML
    End Try

Of course, this abuses the exception handling system  ;o)

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question