質問

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