I have an xml file with more than one attribute that I like to parse with the __XPath function, but the function ignores the attribute name on the second call per request. Example: xmlfile testusers.xml: <users> <user username="u1" password="p1"/> <user username="u2" password="p2"/> </users> the XPath function call ${__XPath(testusers.xml,//user/@username)} will return u1 and u2 respectively, but ${__XPath(testusers.xml,//user/@password)} will also return u1 and u2. XPathWrapper.getXPathString() only checks if it is the same file, should probably check xpathString too
(In reply to comment #0) > the XPath function call > ${__XPath(testusers.xml,//user/@username)} will return u1 and u2 respectively, but > ${__XPath(testusers.xml,//user/@password)} will also return u1 and u2. The above calls are identical, so the response should be identical as well. > XPathWrapper.getXPathString() only checks if it is the same file, should > probably check xpathString too Please explain
(In reply to comment #1) > > the XPath function call > > ${__XPath(testusers.xml,//user/@username)} will return u1 and u2 > respectively, but > > ${__XPath(testusers.xml,//user/@password)} will also return u1 and u2. > > The above calls are identical, so the response should be identical as well. I would expect ${__XPath(testusers.xml,//user/@password)} to return p1 and p2 respectively, the call is asking for a different attribute value (password and not username). If the calls were identical, you couldn't parse more than one attribute from each xml file.
Sorry, my mistake, I misread it - of course ...@username is not the same as ...@password - duh! I now understand the comment about the XPath string check as well. I'll take another look at fixing this.
As far as I can tell, at present each call only ever returns the first match - I could not get the function to return u2 (using your example). Does it work for you? There does not seem to be any code to increment the internal pointer. This obviously needs to be fixed as well... BTW, a work-round at present is to use different file names for the same file, e.g. testusers.xml and ./testusers.xml
I think I've fixed both problems in the 2.1 branch. The nightly build 2-1.20060221 contains the fixes.
Found a problem - the nodelist was not being shared across threads. This is in the 2-1.20060222 build.
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/1667