count number of nodes with a specific attribute value and node value/innerText in vb.net

StackOverflow https://stackoverflow.com/questions/17032766

  •  31-05-2022
  •  | 
  •  

سؤال

I've read MSDN's article on node selection and lots of different posts on determining nodes with specific attributes and nodes with specific values, but I need to count the number of nodes that have both a specific attribute and a specific value.

To count the total number of nodes with a specific name value, I have this:
Dim count6 As Integer = doc4.CreateNavigator().Evaluate("count(//TAG[@NAME='CURRENTTRANAMT'])")

However, I need to know how many of the nodes counted above have a value/InnterText of 00000000000000.00

I'm working with a very oddly structured xml file, one like I've not seen before, and until now have been able to search and sort it as needed, but now I need to create a loop that stops when the value of the node with name CURRENTTRANAMT has the value of 00000000000000.00.

Is there a way to add the 00000000000000.00 value into my dim count6 or am I going to need a different approach?

Writing this out gave me a looping idea that may let me workaround this, but I'm still curious to know if the count above is possible.

Thanks for any suggestions,

David

هل كانت مفيدة؟

المحلول

You could try following addition:

Dim count6 As Integer = doc4.CreateNavigator().Evaluate("count(//TAG[@NAME='CURRENTTRANAMT' and (@value = '00000000000000.00' or @innerText = '00000000000000.00')])")
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top