Pregunta

Currently i'm trying to count the total of items that are selected with xpath.

to count all items i can do:

count(/process_data/formData/xdp/datasets/data/Data//@selected)

but how can i count all items where the value of selected is true. (not knowing the previous node). If i knew the previous node i could do:

count(/process_data/formData/xdp/datasets/data/Data//node[@selected=true]/@selected)

but since i don't know this data, i can't use this. any ideas?

¿Fue útil?

Solución

If you mean by not knowing the previous node that you want to check all nodes that may have a selected attribute I think you just have to change your XPath expression to:

count(/process_data/formData/xdp/datasets/data/Data//*[@selected='true'])

This assumes that selected is actually a string attribute.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top