Domanda

Hi,

I'm trying to set a specific element in a XML, by using xpath. I need it to be in a specific location e.g. /UIM/INVOICE/SECTION/RECORD*[i+1]*

Do i need to use the "position()" method to do that? or how do i do that?

Thanks

È stato utile?

Soluzione

If you construct the XPath expression at runtime and you have an integer value starting with 1 you can simply put that value in the predicate e.g. int pos = i + 1; String path = "/UIM/INVOICE/SECTION/RECORD[" + pos + "]";. That would select the *pos*th RECORD child element.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top