PC Review


Reply
Thread Tools Rate Thread

Checking wether a file is XML or plain text?

 
 
=?Utf-8?B?U3RhbXBlZGU=?=
Guest
Posts: n/a
 
      28th Jul 2005
Hi,
I would like to know if there is any way to check if a file is an XML or a
plain text file?
Opening the file with a FileStream and checking the first character for '<'
seems not very clean and in case of performance not very fast either, as I
would have to open the file twice if it is an XML file. I can't use the file
extension as it is not shure, that every XML file will have the .xml
extension within the system I need this feature.

Hope you can help me with this problem...

Stampede
 
Reply With Quote
 
 
 
 
stic
Guest
Posts: n/a
 
      28th Jul 2005
Not very smart solution, but if you think that the xml is expected
format, try to open file with XmlTextReader() and wait for XmlException
if it isn't well formated XML.

--
best regards.
stic

 
Reply With Quote
 
=?Utf-8?B?UmFodWwgQW5hbmQ=?=
Guest
Posts: n/a
 
      28th Jul 2005
"stic" wrote:

> Not very smart solution, but if you think that the xml is expected
> format, try to open file with XmlTextReader() and wait for XmlException
> if it isn't well formated XML.
>
> --
> best regards.
> stic
>
>


I guess apart from this there is no clean way to differentiate XML file from
text file as XML files are also text files. So you have only option to check
for Well-Form XML.

--
Cheers,
Rahul Anand
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking wether a karakter is a number Erwin Bormans Microsoft Access Form Coding 1 26th Mar 2011 11:53 AM
Plain-text spell check bug in Outlook2007. Spell checking not save =?Utf-8?B?TmVpbCBD?= Microsoft Outlook Discussion 2 20th Jul 2007 10:10 PM
How do I save a file as Text Only versus Plain Text? =?Utf-8?B?SmVzc2k=?= Microsoft Word Document Management 11 6th Jul 2006 05:47 AM
Checking wether a socket is closed Nuno Magalhaes Microsoft C# .NET 2 1st Dec 2005 10:28 AM
Print a plain text file Marlene Arauz Martin Microsoft Dot NET Framework Forms 1 8th Aug 2003 12:33 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:57 AM.