c# - xpath where clause returning 0 nodes -


my clause in xpath expression not working , returning 0. cannot figure out wrong. code here. value of currentrelationship variable 'testentity_relname.';

var entity = doc.selectnodes(string.format("//settings/entity[relationshipname={0}]", currentrelationship)).cast<xmlnode>().tolist(); 

and xml document looks this;

<settings>   <accessrighttypes>     <accessrighttype>writeaccess</accessrighttype>     <accessrighttype>shareaccess</accessrighttype>     <accessrighttype>readaccess</accessrighttype>     <accessrighttype>noneaccess</accessrighttype>     <accessrighttype>deleteaccess</accessrighttype>     <accessrighttype>createaccess</accessrighttype>     <accessrighttype>assignaccess</accessrighttype>     <accessrighttype>appendtoaccess</accessrighttype>     <accessrighttype>appendaccess</accessrighttype>   </accessrighttypes>   <entity>     <relationshipname>testentity_relname.</relationshipname>     <accessright>readaccess</accessright>     <accessright>writeaccess</accessright>   </entity> </settings> 

if use xpath expression of "//settings/entity" single entity node back. again, clause not work. , info appreciated.

looks you're missing single quotes around argument in xpath format string.

var entity = doc.selectnodes(string.format("//settings/entity[relationshipname='{0}']", currentrelationship)).cast<xmlnode>().tolist(); 

Comments

Popular posts from this blog

javascript - IndexedDB error: Uncaught DataCloneError: Failed to execute 'put' on 'IDBObjectStore': An object could not be cloned -

amazon web services - When using Cognito credentials with AWS in a browser (javascript), keep getting "missing credentials" error -

c# - How to set the datatextfield value instead of the value on a drop down list? -