【发布时间】:2021-11-01 17:02:56
【问题描述】:
我正在尝试从包含 json、xml 和 html 的 API 多部分响应中获取值。另外,HTML 在该响应中的元素上没有任何 id 和任何类。我想在一个元素中获取完整的表格,并希望从它的tr 中获取值。请建议我如何在 逻辑应用程序 中的 inline code 中执行此操作。
var response = workflowContext.trigger.outputs.body; // API Response
var multiBody = response.body.$multipart[4].body; // multipartBody
var table = multiBody. // How to get table section and get its tr values
return table;
我已经编写了想要在inline code 连接器中实现的javascript 代码。我的代码是
var rows = document.getElementsByTagName('table')[4].rows;
var firstRow = rows[0]; // LTV/CLTV Row
var firstCell = firstRow.cells[1]; // LTV/CLTV Index
var firstText = firstCell.innerText;
var firstValue = firstText.substring(0, firstText.indexOf('/') - 1); // LTV
var secondValue = firstText.substring(firstText.indexOf('/') + 2, firstText.lastIndexOf('/') - 1); // CLTV
请帮助我如何做到这一点。
另外,正如文档中提到的,我们可以在内联代码连接器中编写 javascript,那么为什么 getElementById、getElementByTagname 函数在这里不起作用。
【问题讨论】:
标签: azure azure-logic-apps inline-code