#XPath 1.0 Functions
--------------------
>From: David Thielen <thielen@nospam.nospam>
>Subject: Re: Why does this XPath not work
>Date: Sun, 20 Jul 2008 21:50:42 -0600
>Same issue with matches()
>
[quoted text clipped - 21 lines]
>
>Cubicle Wars - http://www.windwardreports.com/film.htm
Hi Dave,
Regarding on the error "Namespace manager or XsltContext needed." you
encountered, it is due to the "ends-with" function is not a standard
function in XPATH 1.0.( it is in XPATH 2.0). Currently, .net framework XML
components only implemented XPATH 1.0 and XSLT 1.0 function set, here is
the list of supported functions:
#XPath 1.0 Functions
http://www.edankert.com/xpathfunctions.html
#4.2 String Functions
http://www.w3.org/TR/xpath#section-String-Functions
for your scenario, you may use some other built-in functions to replace the
ends-with call or define some .net custom extension functions:
============use substring to detect end of string============
private void btnQuery_Click(object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();
doc.Load(@"..\..\data.xml");
string xpath =
"/root/customers/customer[substring(./name,string-length(./name),1)='e']";
XmlNodeList nodes = doc.SelectNodes(xpath);
if (nodes != null && nodes.Count > 0)
{
foreach (XmlNode node in nodes)
MessageBox.Show(node.OuterXml);
}
}
=============================
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: David Thielen <thielen@nospam.nospam>
>Subject: Re: Why does this XPath not work
>Date: Sun, 20 Jul 2008 21:50:42 -0600
>Same issue with matches()
>
[quoted text clipped - 21 lines]
>
>Cubicle Wars - http://www.windwardreports.com/film.htm
David Thielen - 21 Jul 2008 16:55 GMT
OK - thanks
>Hi Dave,
>
[quoted text clipped - 93 lines]
>>
>>Cubicle Wars - http://www.windwardreports.com/film.htm
david@at-at-at@windward.dot.dot.net
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com
Cubicle Wars - http://www.windwardreports.com/film.htm