Connecting Tech Pros Worldwide Forums | Help | Site Map

Url validation

Erik Cruz
Guest
 
Posts: n/a
#1: Nov 11 '05
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



Chris Lovett
Guest
 
Posts: n/a
#2: Nov 11 '05

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