Question

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

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top