c# - SelectNodes with Filter -
here xml:
<instrument recordcount="3" > <department id = 18384, sequence=1> <instrumentdata statuscode="1" roletype="ed" style="x" dataother='data'> </department> <department id = 18465, sequence=2> <instrumentdata statuscode="2" roletype="cd" style="s" dataother='data'> </department> <department id = 16473, sequence=3> <instrumentdata statuscode="1" roletype="cd" style="t" dataother='data'> </department> </instrument>
i want @status attribute ='1' or '2' , not @roletype='e' , 'f' , @style ='s' , 't' each node.
i have following statement, not bring correct results.
xmlnodelist nodelist = root.selectnodes(@"//department[instrumentdata/@status='1' or department[instrumentdata/@status='1' , not (department[instrumentdata/@roletype='e' or department[instrumentdata/@roletype='f') , (department[instrumentdata/@style='s' or department[instrumentdata/@style='t') ]", manager);
or first need first condition, build xml doc, next condition.
thanks.
there no problem have complex conditions in xpaht expressions. example can not work because of mistakes.
* brackets (]
) missing
* there no status attribute in example xml.
* cant use "or" put note list.
example: if try departments instrumentdata/@statuscode = 2
, departments instrumentdata/@style= t
.
the following not work:
nodelist = root.selectnodes("//department[instrumentdata/@statuscode='2'] or //department[instrumentdata/@style='t' ]");
but can either:
nodelist = root.selectnodes("//department[instrumentdata/@statuscode='2'] | //department[instrumentdata/@style='t' ]");
or (in view better):
nodelist = root.selectnodes("//department[instrumentdata/@statuscode='2' or instrumentdata/@style='t' ]");
Comments
Post a Comment