Connecting Tech Pros Worldwide Help | Site Map

Url validation

  #1  
Old November 11th, 2005, 10:49 PM
Erik Cruz
Guest
 
Posts: n/a
A custom xml file I wrote for my application has two elements that accepts
urls. I used vs.net to generate a schema file for my file but there is no
validation for urls. How can I validate an element to accept valid urls
including https ones?

TIA,

Erik Cruz


  #2  
Old November 11th, 2005, 10:49 PM
Chris Lovett
Guest
 
Posts: n/a

re: Url validation


The best you can do with XSD is the primitive type called "anyURI". Beyond
that you'll have to write code. You can use the System.Uri class:

try {
Uri uri = new Uri(node.InnerText);
// here you might also want to check the Uri "scheme" to make sure it is
one you accept, like http, https, and file.
} catch (Exception e) {
// then it was a bad URL...
}

"Erik Cruz" <erikacf.nospam@antares.com.br> wrote in message
news:%23lN6xRjTDHA.1912@tk2msftngp13.phx.gbl...[color=blue]
> A custom xml file I wrote for my application has two elements that accepts
> urls. I used vs.net to generate a schema file for my file but there is no
> validation for urls. How can I validate an element to accept valid urls
> including https ones?
>
> TIA,
>
> Erik Cruz
>
>[/color]


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
java script for url validation khushwinder answers 11 April 14th, 2008 11:56 AM
Regular expression for URL validation sangram answers 2 December 9th, 2006 06:45 PM
URL Validation in Windows Forms shankar answers 1 November 17th, 2005 04:13 AM
URL validation Shahzad Atta answers 3 November 16th, 2005 12:21 PM