【问题标题】:How do I extract a variable within namespace from XML using Postman?如何使用 Postman 从 XML 中提取命名空间内的变量?
【发布时间】:2017-03-15 15:58:23
【问题描述】:

我正在尝试使用此链接How do I extract a variable from XML using Postman?中描述的相同方法提取会话令牌

已经在网上搜索过,但没有运气。

我的 xml 有一个命名空间 se:security

se 是命名空间,security 是元素。令牌在子代中。

因此,如果我深入研究,我想它将是安全性 - 二进制代码 - 令牌(变量所在的位置)

但它不起作用。是因为命名空间se吗?

我在 Postman 测试窗口中执行以下操作。

var responseJson = xml2Json(responseBody);
console.log(responseJson);
postman.setEnvironmentVariable("Token", responseJson.se.security.token);

【问题讨论】:

  • 你能展示你的 XML 或具有相同结构的东西吗?

标签: json xml postman jsonpath for-xml-path


【解决方案1】:

对我有用的是:

postman.setEnvironmentVariable("Token", responseJson['se:security']);

我发现的主要内容:

  • 任何带有命名空间的键都不带“.”
  • 带有命名空间的键必须有方括号和引号
  • 任何没有命名空间的键只使用“.”

例如:

postman.setEnvironmentVariable("Token", responseJson['se:security'].without['se:with']['se:with'].without.without

【讨论】:

    猜你喜欢
    • 2016-08-17
    • 2012-01-08
    • 2021-09-10
    • 2016-05-14
    • 1970-01-01
    • 2016-07-28
    • 2015-07-18
    • 1970-01-01
    • 2018-07-22
    相关资源
    最近更新 更多