xml - Comparing root node text XPATH -
i want comparison on node text value. facing issues in it.
case 1:
<xmldata> <studentdatas noofstudents="67">myschool</studentdatas> </xmldata>
/xmldata/studentdatas/text()[.=normalize-space('myschool')]
- working.
but following case, not working:-
<studentdatas>myschooldetails <class_a noofstudents="67" class_teacher="dhanpal"> <studentdata category="highclass"> <student id="1010" name="n1" bloodgroup="a+" /> <student id="1011" name="n2" bloodgroup="b+" /> <student id="1012" name="n3" bloodgroup="c+" /> </studentdata> </class_a> </studentdatas>
here want select noofstudent attribute,when root node text matched given text:
/studentdatas/class_a/@noofstudents[../text()='myschooldetails']
but query not working.
may kindly know how, mistaking.
first check parent, child's attribute:
/studentdatas[normalize-space(.)='myschooldetails']/class_a/@noofstudents
demo using xmllint
:
$ xmllint input.xml --xpath "/studentdatas[normalize-space(.)='myschooldetails']/class_a/@noofstudents" noofstudents="67"
Comments
Post a Comment