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