Site Map       
Web Services
XML Schema
XSLT and XPath
XML Serialization
Database and XML
XML Query
Contact Info

.NET Notes

Sample Code for this Program can be found at the bottom right hand side of this page.


XPath Query Expression Tool

Enter an XPath Query Expression and click the Test XPath Button. You can use the default document in the XML Document TextBox or replace the default document with one of your own.

Xpath Query Expression:


XML Document:

'XPath Query Expression Tool Sample Code


            XpDoc = New XPathDocument(XmlDocument)
            XpNav = XpDoc.CreateNavigator
            XpExp = XpNav.Compile(TextBox1.Text)
            XpNodeIterate = XpNav.Select(XpExp)

            If XpNodeIterate.Count = 0 Then
                lblResults.ForeColor = Yellow
                lblResults.Text = "No matching nodes were found"
                Do While XpNodeIterate.MoveNext
                    lblResults.Text = lblResults.Text & XpNodeIterate.Current.Value
            End If

        Catch XmlException As System.Xml.XmlException
            lblResults.ForeColor = Red
            lblResults.Text = "XML Error: " & XmlException.ToString

        Catch XpException As System.Xml.XPath.XPathException
            lblResults.ForeColor = Red
            lblResults.Text = "XPath Error: " & XpException.ToString

        End Try

Copyright © 2015 Seanco Technology, Inc.  All rights reserved.