Re: Why does this XPath not work



OK - thanks


On Mon, 21 Jul 2008 04:38:14 GMT, stcheng@xxxxxxxxxxxxxxxxxxxx (Steven
Cheng [MSFT]) wrote:

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@xxxxxxxxxxxxxx

==================================================
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@xxxxxxxxxxxxx>
Subject: Re: Why does this XPath not work
Date: Sun, 20 Jul 2008 21:50:42 -0600


Same issue with matches()



On Sun, 20 Jul 2008 21:45:04 -0600, David Thielen
<thielen@xxxxxxxxxxxxx> wrote:

This XPath works fine:
/order/customer[(./address/@zip = 80302) and
(starts-with(./name,'J'))]

But this XPath :
/order/customer[(./address/@zip = 80302) and (ends-with(./name,'J'))]

ends-with() is standard XPath but I get the error: Namespace manager
or XsltContext needed.

??? - thanks - dave

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


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



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
.



Relevant Pages

  • RE: ASP.Net timeouts
    ... There's no managed call stack on the thread that throws this exception. ... Microsoft Online Support ... You can send feedback directly to my manager at: ... nature are best handled working with a dedicated Microsoft Support Engineer ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Theming not working in DLL
    ... the resource ID for a manifest in a DLL is typically different ... Microsoft Online Community Support ... You can send feedback directly to my manager at: ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.win32.programmer.ui)
  • RE: Linking Mixed Mode and Managed Assemblies
    ... public void f ... Microsoft Online Community Support ... You can send feedback directly to my manager at: ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.languages.vc)
  • RE: Web Administration Tool Crashes when creating user
    ... It will check if the Role Manager has been enabled. ... It is reusing the default connection string name: ... Microsoft Online Community Support ... nature are best handled working with a dedicated Microsoft Support Engineer ...
    (microsoft.public.vsnet.setup)
  • RE: Fix 954345 does not resolve problem for VS 2008 SP1
    ... My name is Hongye and it ... Microsoft Online Community Support ... You can send feedback directly to my manager at: ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.vsnet.general)

Loading