xml - 从 Azure 逻辑应用中的 XML 文档解析 Word 格式的文本
问题描述
我正在尝试从 SharePoint 表单库中解析 XML 文件,其中用户已将格式化的 Word 文档文本复制/粘贴到文本字段中。结果是 XML 中的 XML。我在获取内容时遇到了麻烦,但在另一个问题的帮助下,这种语法有效xpath(xml(outputs('Get_file_content')?['body']),'//*[local-name()="myFields"]//following-sibling::*[local-name()="Request_Description"]')[0]
。结果是这样的
<my:Request_Description xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2017-05-05T14:19:13">
<xhtml:html xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml">
<xhtml:div>
<xhtml:font size="1" face="CIDFont+F6">
<xhtml:font size="1" face="CIDFont+F6">
<xhtml:p>This is where the request description goes and the result we want</xhtml:p>
</xhtml:font>
</xhtml:font>
</xhtml:div>
</xhtml:html>
</my:Request_Description>
如何仅提取描述文本?我想知道是否xpath
需要调整我的第一个语句以免拉回整个元素。
更新 - 我没有提到上面只是用户输入该字段的一个示例,每个表单都会有所不同。例如,这里是可以在该字段中找到的另一个示例。
<my:Request_Description xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2017-05-05T14:19:13">
<xhtml:html xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml">
<xhtml:div>test random double quote inside title "here" test and carriage<xhtml:br />return</xhtml:div>
</xhtml:html>
</my:Request_Description>
这是由表单上的 RTF 控件引起的,用户可以在该控件中输入表单上的文本框,然后该控件将其转换为您看到的 XML。由于没有一致性,我想知道 usingxpath
是否不是一个可行的选择,但我不确定还能做什么。
解决方案
你可以使用这个表达式:
xpath(xml(outputs('Get_file_content')?['body']), 'string(/*[local-name()="Request_Description"]/*[local-name()="html"]/*[local-name()="div"]/*[local-name()="font"]/*[local-name()="font"]/*[local-name()="p"])')
可以参考这个官方文档来参考xpath
.
=========================更新========================= ==
您可以使用trim,然后使用此表达式:
trim(xpath(xml(outputs('Get_file_content')?['body']), 'string(/*[local-name()="Request_Description"])'))
推荐阅读
- sql-server-2014 - 如何屏蔽某些特定用户的字段值?
- sql - 用于将日期(dd/mm/yyyy 转换为 yyyyQ1)的 SQLite 代码在 BigQuery SQL 编辑器中不起作用
- javascript - 如何使用 POST 保存从 NodeJS 发送的文件
- amazon-web-services - AWS VPC 客户端终端节点
- integration - 如何在主干应用程序中集成 Lokalise 的复数?
- r - 从比较过程中生成数据框
- html - 如何修复我的媒体查询以更改文本大小?
- javascript - Vue从数据中的函数访问数据
- java - Apache flink 分区
- powershell - 使当前项目 ($_ / $PSItem) 可用于模块函数中的脚本块参数