Вопрос

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

Это было полезно?

Решение

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top