EDN Admin
Well-known member
<br/>
Hi all;<br/>
<br/>
Ive got an XPath expression with a predicate that selects<br/>
a persons name and ID from within a nested element, using<br/>
the XPathNavigator.Select method.<br/>
<br/>
This works:<br/>
root/all_clients/client/client_name_and_ID[client_ID = xxx]<br/>
<br/>
This also works:<br/>
root/all_clients/client[client_name_and_ID/client_ID = xxx]/client_name_and_ID<br/>
<br/>
When I take the predicate to the next level, it does not work:<br/>
root/all_clients[client/client_name_and_ID/client_ID = xxx]/client/client_name_and_ID<br/>
<br/>
I do not get any filtering, but the entire set.<br/>
<br/>
Is this due to a limitation inherent within XPath, within ASP.NET,<br/>
or am I doing something stupid?<br/>
<br/>
What follows is a snippet from the relevant XML file:<br/>
<br/>
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <?<span style="color:#A31515; xml <span style="color:Red; version<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1.0<span style="color:Black; " <span style="color:Red; encoding<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; utf-8<span style="color:Black; "<span style="color:Blue; ?>
<span style="color:Blue; <<span style="color:#A31515; root <span style="color:Red; xmlns:xsi<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; http://www.w3.org/2001/XMLSchema-instance<span style="color:Black; "
<span style="color:Red; xsi:noNamespaceSchemaLocation<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; file:///nrojectsXMLMedicalExample_01.xsd<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; all_clients<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; client<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; client_name_and_ID<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; first_name<span style="color:Blue; >Fred<span style="color:Blue; </<span style="color:#A31515; first_name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; middle_name<span style="color:Blue; >James<span style="color:Blue; </<span style="color:#A31515; middle_name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; last_name<span style="color:Blue; >Bowman<span style="color:Blue; </<span style="color:#A31515; last_name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; client_ID<span style="color:Blue; >1<span style="color:Blue; </<span style="color:#A31515; client_ID<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; client_name_and_ID<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; client<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; client<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; client_name_and_ID<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; first_name<span style="color:Blue; >Mark<span style="color:Blue; </<span style="color:#A31515; first_name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; middle_name<span style="color:Blue; >David<span style="color:Blue; </<span style="color:#A31515; middle_name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; last_name<span style="color:Blue; >Colder<span style="color:Blue; </<span style="color:#A31515; last_name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; client_ID<span style="color:Blue; >2<span style="color:Blue; </<span style="color:#A31515; client_ID<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; client_name_and_ID<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; client<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; client<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; client_name_and_ID<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; first_name<span style="color:Blue; >Joe<span style="color:Blue; </<span style="color:#A31515; first_name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; last_name<span style="color:Blue; >Lewis<span style="color:Blue; </<span style="color:#A31515; last_name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; client_ID<span style="color:Blue; >3<span style="color:Blue; </<span style="color:#A31515; client_ID<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; client_name_and_ID<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; client<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; client<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; client_name_and_ID<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; first_name<span style="color:Blue; >Sam<span style="color:Blue; </<span style="color:#A31515; first_name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; last_name<span style="color:Blue; >Plank<span style="color:Blue; </<span style="color:#A31515; last_name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; client_ID<span style="color:Blue; >4<span style="color:Blue; </<span style="color:#A31515; client_ID<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; client_name_and_ID<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; client<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; all_clients<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; root<span style="color:Blue; >
[/code]
<br/>
THANKS!!!
<hr class="sig Wally
View the full article
Hi all;<br/>
<br/>
Ive got an XPath expression with a predicate that selects<br/>
a persons name and ID from within a nested element, using<br/>
the XPathNavigator.Select method.<br/>
<br/>
This works:<br/>
root/all_clients/client/client_name_and_ID[client_ID = xxx]<br/>
<br/>
This also works:<br/>
root/all_clients/client[client_name_and_ID/client_ID = xxx]/client_name_and_ID<br/>
<br/>
When I take the predicate to the next level, it does not work:<br/>
root/all_clients[client/client_name_and_ID/client_ID = xxx]/client/client_name_and_ID<br/>
<br/>
I do not get any filtering, but the entire set.<br/>
<br/>
Is this due to a limitation inherent within XPath, within ASP.NET,<br/>
or am I doing something stupid?<br/>
<br/>
What follows is a snippet from the relevant XML file:<br/>
<br/>
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <?<span style="color:#A31515; xml <span style="color:Red; version<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1.0<span style="color:Black; " <span style="color:Red; encoding<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; utf-8<span style="color:Black; "<span style="color:Blue; ?>
<span style="color:Blue; <<span style="color:#A31515; root <span style="color:Red; xmlns:xsi<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; http://www.w3.org/2001/XMLSchema-instance<span style="color:Black; "
<span style="color:Red; xsi:noNamespaceSchemaLocation<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; file:///nrojectsXMLMedicalExample_01.xsd<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; all_clients<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; client<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; client_name_and_ID<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; first_name<span style="color:Blue; >Fred<span style="color:Blue; </<span style="color:#A31515; first_name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; middle_name<span style="color:Blue; >James<span style="color:Blue; </<span style="color:#A31515; middle_name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; last_name<span style="color:Blue; >Bowman<span style="color:Blue; </<span style="color:#A31515; last_name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; client_ID<span style="color:Blue; >1<span style="color:Blue; </<span style="color:#A31515; client_ID<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; client_name_and_ID<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; client<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; client<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; client_name_and_ID<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; first_name<span style="color:Blue; >Mark<span style="color:Blue; </<span style="color:#A31515; first_name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; middle_name<span style="color:Blue; >David<span style="color:Blue; </<span style="color:#A31515; middle_name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; last_name<span style="color:Blue; >Colder<span style="color:Blue; </<span style="color:#A31515; last_name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; client_ID<span style="color:Blue; >2<span style="color:Blue; </<span style="color:#A31515; client_ID<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; client_name_and_ID<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; client<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; client<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; client_name_and_ID<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; first_name<span style="color:Blue; >Joe<span style="color:Blue; </<span style="color:#A31515; first_name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; last_name<span style="color:Blue; >Lewis<span style="color:Blue; </<span style="color:#A31515; last_name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; client_ID<span style="color:Blue; >3<span style="color:Blue; </<span style="color:#A31515; client_ID<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; client_name_and_ID<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; client<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; client<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; client_name_and_ID<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; first_name<span style="color:Blue; >Sam<span style="color:Blue; </<span style="color:#A31515; first_name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; last_name<span style="color:Blue; >Plank<span style="color:Blue; </<span style="color:#A31515; last_name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; client_ID<span style="color:Blue; >4<span style="color:Blue; </<span style="color:#A31515; client_ID<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; client_name_and_ID<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; client<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; all_clients<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; root<span style="color:Blue; >
[/code]
<br/>
THANKS!!!
<hr class="sig Wally
View the full article