2013-03-20 25 views
0

我有一種情況,在我嘗試讀取外部XML的節點值時,我使用BeanShell取樣器讀取fileName(通過命令傳遞線),並使用setProperty方法設定所解析的節點的值:

${__setProperty(variable_name,${__XPath(${__P(fileName)},/Allocations/item/@name)})} 

儘管以上方法檢索我打算接收的節點的值,則存在引發一個錯誤:

2013/03/19 19:32:59 ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: `` D:\myProject\Jmeter Tests\allocate.xml ;'' Token Parsing Error: Lexical error at line 2, column 3. Encountered: "\" (92), after : ""

我xml文件看起來像這樣:

<?xml version="1.0" encoding="UTF-8"?> 
<Allocations> 
    <item name="CAR" /> 
</Allocations> 

如果我在閱讀過程中出現錯誤,請多多指教。

回答

0

很奇怪,因爲看起來你做的一切都是正確的。
我已經一步一步地複製了你的場景,但對我來說工作正常。

嘗試使用例如Debug Sampler/Debug PostProcessor來監視您的jmeter屬性,並確保fileName通常從命令行設置,並且不包含任何額外的符號。