Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / February 2008

Tip: Looking for answers? Try searching our database.

Validating XPath

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
arunairs@gmail.com - 25 Jan 2008 08:45 GMT
Hi,
 Is there a way of validating and XPath?  In this case , I am
accepting an XPath from the user and I need to validate the XPath
syntax.  Is there a regular expression available that anyone can
direct me to, to validate a XPath?

thanks,

Arun
Martin Honnen - 25 Jan 2008 12:28 GMT
>   Is there a way of validating and XPath?  In this case , I am
> accepting an XPath from the user and I need to validate the XPath
> syntax.  Is there a regular expression available that anyone can
> direct me to, to validate a XPath?

The W3C has an applet that checks the grammar of an XPath expression:
<URL:http://www.w3.org/2002/11/xquery-xpath-applets/xpathApplet.html>.
I think however that applet is for XPath 2.0 while the Microsoft .NET
framework application currently support XPath 1.0 only. You might want
to check the W3C web site whether an applet checking XPath 1.0 is
available too.

Signature

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/

Phil Fearon - 08 Feb 2008 07:57 GMT
Yes, there is a way of validating the syntax of an XPath expression in .NET,
though it will not pick up all types of errors (Some errors only occur when
the express is run against an XML instance).

Use the 'Compile' method of the XPathNavigator to return a compiled
XPathExpression. This method call will result in an XPathException if the
XPath expression is invalid, you can handle the exception in your code. Note
that this is only a 'static' check and will not pick up errors such as
missing namespace context etc.

A regular expression wouldn't do because of the composability of XPath
(nested predicates and functions and so on).

> >   Is there a way of validating and XPath?  In this case , I am
> > accepting an XPath from the user and I need to validate the XPath
[quoted text clipped - 7 lines]
> to check the W3C web site whether an applet checking XPath 1.0 is
> available too.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.