加入所有P标签XPath Power Automate

发布于 2025-01-27 23:17:18 字数 9926 浏览 2 评论 0 原文

一直在挣扎着流动,以在HTML表中添加Excel中的行。

我遵循了youtube

这将遍历所有项目,然后检索第一个p 1 ,下一个迭代p 2 等等。 “ XPATH(XML(XML('XMLHTML'))),Concat('// Table [.1] // TR [.2] // td [.1] // P [',item(item(Item(),']/ /text()'))?[0]”

但是,就我而言,它看起来像这样

< p class =“ msonormal”> < span lang =“ en-us” style =“ font-size:11.0pt; color:black; border; border:note windowtext 1.0pt; padding; padding; padding:0cm“> glu900 l700/800/800/1800< lt;/span> < span lang =“ en-us” style =“ font-size:11.0pt; border:none windowText 1.0pt; padding; padding:0cm“>/2100/2600/2602;</span> < span lang =“ en-us” style =“ font-size:11.0pt; color:black; border:none window text 1.0pt; padding; padding:0cm“> 5g;<</span> < span lang =“ en-us” style =“ font-size:11.0pt; border:note window Text 1.0pt; padding; padding:0cm“> 3< span style =“ color:color:black”>行业</span></span> </p>

”图片“

​png“ rel =” nofollow noreferrer“> 2 // td 3 // p [.1] // text()“

我只会检索第一项。 我想将所有5个元素加入同一字符串,然后在下一组P标签中迭代

这是我发现的,但是当它不以xpath中的text()函数结尾时,我不知道如何迭代它。 XPATH(XML(XML('XMLHTML'))),'字符串(// Table // tr 2 // td 3 // p [',item(),'])')?[0]

错误消息

模板操作的执行“选择”失败:评估 '查询'动作'其中'expression'{“ funcid”: “ @xpath(xml(upputs('xmlhtml')), concat('// table 1 // tr 2 // td 1 // p [',item(),'] // text()'))?[0]”, “ siteName”:“ @xpath(xml(uptoughs('xmlhtml')), concat('// table 1 // tr 2 // td 2 // p [',item(),'] // text()')?[0]”, “技术”:“ @xpath(xml(XML('xmlhtml')),), 'string(//表 1 // tr 2 // td 3 // p [',item(),'])')?[0]”,“注释”: “ @xpath(xml(upputs('xmlhtml')),), concat('// table 1 // tr 2 // td 4 // p [',item(),'] // text()'))?[0]”}' 失败:“模板语言函数” XPath期望两个 参数:XML对象和XPATH表达式。功能是 用“ 4”参数调用。请看看 https://aka.ms/logicexpressions#xpath 用于用法的详细信息。

所以,最后 我如何将P-TAG列表中的所有5个元素串联到一行中,如何通过Power Automate中的元素迭代?

<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" width="939"
style="width:703.95pt; margin-left:.1pt; border-collapse:collapse">
<tbody>
    <tr style="height:15.75pt">
        <td width="54" nowrap=""
            style="width:40.8pt; border:solid windowtext 1.0pt; padding:0cm 3.5pt 0cm 3.5pt; height:15.75pt">
            <p class="MsoNormal"><b><span
                        style="font-size:11.0pt; color:black; border:none windowtext 1.0pt; padding:0cm">FuncID</span></b>
            </p>
        </td>
        <td width="197" nowrap=""
            style="width:147.45pt; border:solid windowtext 1.0pt; border-left:none; padding:0cm 3.5pt 0cm 3.5pt; height:15.75pt">
            <p class="MsoNormal"><b><span
                        style="font-size:11.0pt; color:black; border:none windowtext 1.0pt; padding:0cm">SiteName</span></b>
            </p>
        </td>
        <td width="485" nowrap=""
            style="width:364.1pt; border:solid windowtext 1.0pt; border-left:none; padding:0cm 3.5pt 0cm 3.5pt; height:15.75pt">
            <p class="MsoNormal"><b><span
                        style="font-size:11.0pt; color:black; border:none windowtext 1.0pt; padding:0cm">Technology</span></b>
            </p>
        </td>
        <td width="202" nowrap=""
            style="width:151.6pt; border:solid windowtext 1.0pt; border-left:none; padding:0cm 3.5pt 0cm 3.5pt; height:15.75pt">
            <p class="MsoNormal"><b><span style="font-size:11.0pt; color:black">Comments</span></b></p>
        </td>
    </tr>
    <tr style="height:43.4pt">
        <td width="54" nowrap=""
            style="width:40.8pt; border:solid windowtext 1.0pt; border-top:none; padding:0cm 3.5pt 0cm 3.5pt; height:43.4pt">
            <p class="MsoNormal"><span style="font-size:11.0pt">T223566</span></p>
            <p class="MsoNormal"><span style="font-size:11.0pt">T335125</span></p>
            <p class="MsoNormal"><span style="font-size:11.0pt">T311000</span></p>
        </td>
        <td width="197" nowrap=""
            style="width:147.45pt; border-top:none; border-left:none; border-bottom:solid windowtext 1.0pt; border-right:solid windowtext 1.0pt; padding:0cm 3.5pt 0cm 3.5pt; height:43.4pt">
            <p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">Testing1 test1 test1</span></p>
            <p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">Testing2 test2 test2</span></p>
            <p class="MsoNormal"><span lang="EN-US">Testing 3 test3 test3</span></p>
        </td>
        <td width="485" nowrap=""
            style="width:364.1pt; border-top:none; border-left:none; border-bottom:solid windowtext 1.0pt; border-right:solid windowtext 1.0pt; padding:0cm 3.5pt 0cm 3.5pt; height:43.4pt">
            <p class="MsoNormal"><span lang="EN-US">GLU900 L700/800/1800/2100/2600/2602 5G 4 Sec</span>tor<span
                    lang="EN-US"></span></p>
            <p class="MsoNormal"><span lang="EN-US">&nbsp;</span></p>
            <p class="MsoNormal"><span lang="EN-US"
                    style="font-size:11.0pt; color:black; border:none windowtext 1.0pt; padding:0cm">GLU900
                    L700/800/1800</span><span lang="EN-US"
                    style="font-size:11.0pt; border:none windowtext 1.0pt; padding:0cm">/2100/2600/2602
                    &nbsp;</span><span lang="EN-US"
                    style="font-size:11.0pt; color:black; border:none windowtext 1.0pt; padding:0cm">5G
                    &nbsp;</span><span lang="EN-US"
                    style="font-size:11.0pt; border:none windowtext 1.0pt; padding:0cm">5</span><span lang="EN-US"
                    style="font-size:11.0pt; color:black; border:none windowtext 1.0pt; padding:0cm"> sector</span>
            </p>
        </td>
        <td width="202" nowrap=""
            style="width:151.6pt; border-top:none; border-left:none; border-bottom:solid windowtext 1.0pt; border-right:solid windowtext 1.0pt; padding:0cm 3.5pt 0cm 3.5pt; height:43.4pt">
            <p class="MsoNormal"><span lang="EN-US"
                    style="font-size:11.0pt; border:none windowtext 1.0pt; padding:0cm">&nbsp;</span></p>
            <p class="MsoNormal"><span lang="EN-US"
                    style="font-size:11.0pt; color:black; border:none windowtext 1.0pt; padding:0cm">5G will be
                    activated tomorrow</span></p>
            <p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">3-D</span></p>
        </td>
    </tr>
</tbody>

br erik

更新流

“选择”流的结果

原始电子邮件

Been struggling with a flow to add rows in excel from html table.

I've followed this guide from youtube Youtube
and it works with the first p tag
But i want to join all ptags to same string.

This will iterate through all items and retrieve the first p1, next iteration p2 and so on..
"xpath(xml(outputs('XMLHTML')), concat('//table[.1]//tr[.2]//td[.1]//p[',item(),']//text()'))?[0]"

But in my case it looks like this
Select flow in power automate

<p class="MsoNormal"> <span lang="EN-US" style="font-size:11.0pt; color:black; border:none windowtext 1.0pt; padding:0cm">GLU900 L700/800/1800</span> <span lang="EN-US" style="font-size:11.0pt; border:none windowtext 1.0pt; padding:0cm">/2100/2600/2602 ;</span> <span lang="EN-US" style="font-size:11.0pt; color:black; border:none windowtext 1.0pt; padding:0cm">5G ;</span> <span lang="EN-US" style="font-size:11.0pt; border:none windowtext 1.0pt; padding:0cm">3<span style="color:black"> sector</span></span> </p>

picture

enter image description here

"//table[.1]//tr2//td3//p[.1]//text()"

And i will only retrieve the first item.
I want to join all 5 element to same string and then iterate through the next set of p tags

this is what i've found, but I dont know how to iterate through this when its not ending with a text() function in xpath
xpath(xml(outputs('XMLHTML')), 'string(//table1//tr2//td3//p[',item(),'])')?[0]

Error Message

The execution of template action 'Select' failed: The evaluation of
'query' action 'where' expression '{ "FuncID":
"@xpath(xml(outputs('XMLHTML')),
concat('//table1//tr2//td1//p[',item(),']//text()'))?[0]",
"SiteName": "@xpath(xml(outputs('XMLHTML')),
concat('//table1//tr2//td2//p[',item(),']//text()'))?[0]",
"Technology": "@xpath(xml(outputs('XMLHTML')),
'string(//table1//tr2//td3//p[',item(),'])')?[0]", "Comment":
"@xpath(xml(outputs('XMLHTML')),
concat('//table1//tr2//td4//p[',item(),']//text()'))?[0]" }'
failed: 'The template language function 'xpath' expects two
parameters: an XML object and an XPath expression. The function was
invoked with '4' parameter(s). Please see
https://aka.ms/logicexpressions#xpath for usage details.'.

So, at the end
How do i concatenate all 5 elements in list of p-tags to one line and how do i iterate through the elements in power automate??

<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" width="939"
style="width:703.95pt; margin-left:.1pt; border-collapse:collapse">
<tbody>
    <tr style="height:15.75pt">
        <td width="54" nowrap=""
            style="width:40.8pt; border:solid windowtext 1.0pt; padding:0cm 3.5pt 0cm 3.5pt; height:15.75pt">
            <p class="MsoNormal"><b><span
                        style="font-size:11.0pt; color:black; border:none windowtext 1.0pt; padding:0cm">FuncID</span></b>
            </p>
        </td>
        <td width="197" nowrap=""
            style="width:147.45pt; border:solid windowtext 1.0pt; border-left:none; padding:0cm 3.5pt 0cm 3.5pt; height:15.75pt">
            <p class="MsoNormal"><b><span
                        style="font-size:11.0pt; color:black; border:none windowtext 1.0pt; padding:0cm">SiteName</span></b>
            </p>
        </td>
        <td width="485" nowrap=""
            style="width:364.1pt; border:solid windowtext 1.0pt; border-left:none; padding:0cm 3.5pt 0cm 3.5pt; height:15.75pt">
            <p class="MsoNormal"><b><span
                        style="font-size:11.0pt; color:black; border:none windowtext 1.0pt; padding:0cm">Technology</span></b>
            </p>
        </td>
        <td width="202" nowrap=""
            style="width:151.6pt; border:solid windowtext 1.0pt; border-left:none; padding:0cm 3.5pt 0cm 3.5pt; height:15.75pt">
            <p class="MsoNormal"><b><span style="font-size:11.0pt; color:black">Comments</span></b></p>
        </td>
    </tr>
    <tr style="height:43.4pt">
        <td width="54" nowrap=""
            style="width:40.8pt; border:solid windowtext 1.0pt; border-top:none; padding:0cm 3.5pt 0cm 3.5pt; height:43.4pt">
            <p class="MsoNormal"><span style="font-size:11.0pt">T223566</span></p>
            <p class="MsoNormal"><span style="font-size:11.0pt">T335125</span></p>
            <p class="MsoNormal"><span style="font-size:11.0pt">T311000</span></p>
        </td>
        <td width="197" nowrap=""
            style="width:147.45pt; border-top:none; border-left:none; border-bottom:solid windowtext 1.0pt; border-right:solid windowtext 1.0pt; padding:0cm 3.5pt 0cm 3.5pt; height:43.4pt">
            <p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">Testing1 test1 test1</span></p>
            <p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">Testing2 test2 test2</span></p>
            <p class="MsoNormal"><span lang="EN-US">Testing 3 test3 test3</span></p>
        </td>
        <td width="485" nowrap=""
            style="width:364.1pt; border-top:none; border-left:none; border-bottom:solid windowtext 1.0pt; border-right:solid windowtext 1.0pt; padding:0cm 3.5pt 0cm 3.5pt; height:43.4pt">
            <p class="MsoNormal"><span lang="EN-US">GLU900 L700/800/1800/2100/2600/2602 5G 4 Sec</span>tor<span
                    lang="EN-US"></span></p>
            <p class="MsoNormal"><span lang="EN-US"> </span></p>
            <p class="MsoNormal"><span lang="EN-US"
                    style="font-size:11.0pt; color:black; border:none windowtext 1.0pt; padding:0cm">GLU900
                    L700/800/1800</span><span lang="EN-US"
                    style="font-size:11.0pt; border:none windowtext 1.0pt; padding:0cm">/2100/2600/2602
                     </span><span lang="EN-US"
                    style="font-size:11.0pt; color:black; border:none windowtext 1.0pt; padding:0cm">5G
                     </span><span lang="EN-US"
                    style="font-size:11.0pt; border:none windowtext 1.0pt; padding:0cm">5</span><span lang="EN-US"
                    style="font-size:11.0pt; color:black; border:none windowtext 1.0pt; padding:0cm"> sector</span>
            </p>
        </td>
        <td width="202" nowrap=""
            style="width:151.6pt; border-top:none; border-left:none; border-bottom:solid windowtext 1.0pt; border-right:solid windowtext 1.0pt; padding:0cm 3.5pt 0cm 3.5pt; height:43.4pt">
            <p class="MsoNormal"><span lang="EN-US"
                    style="font-size:11.0pt; border:none windowtext 1.0pt; padding:0cm"> </span></p>
            <p class="MsoNormal"><span lang="EN-US"
                    style="font-size:11.0pt; color:black; border:none windowtext 1.0pt; padding:0cm">5G will be
                    activated tomorrow</span></p>
            <p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">3-D</span></p>
        </td>
    </tr>
</tbody>

BR Erik

Update Flow

enter image description here
enter image description here

Result from "select" flow
enter image description here

Original email
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

倾`听者〃 2025-02-03 23:17:18

首先,为了使它起作用,我必须从您的HTML中删除&amp; nbsp; 数据,它不喜欢它。看看你的状况。

您的XPath查询有一些选择,这完全取决于您想要实现的内容的细节。例如,尝试这些...

// p/span/text()

T223566
T335125
T311000
Testing1 test1 test1
Testing2 test2 test2
Testing 3 test3 test3
GLU900 L700/800/1800/2100/2600/2602 5G 4 Sec

// p/descendant ::*/text()

FuncID

                    

                        
SiteName

                    

                        
Technology

                    

                        
Comments

                    
T223566
T335125
T311000
Testing1 test1 test1
Testing2 test2 test2
Testing 3 test3 test3
GLU900 L700/800/1800/2100/2600/2602 5G 4 Sec

取决于您选择的哪个,它们将返回一个值数组,如果外观,它将忽略所有空白行。

我在流中使用了第二个XPath查询测试,该查询产生以下结果...

“

这是初始化一个包含HTML数据的变量后的步骤(再次,删除&amp; amp; nbsp; 值)...

xpath(xml(variables('XML')), '//p/descendant::*/text()')

Firstly, to make it work, I had to remove the   data from your HTML, it didn't like it. See how you go though.

There are a few options for your XPath query, it all depends on the specifics of what you want to achieve. Try these for example ...

//p/span/text()

T223566
T335125
T311000
Testing1 test1 test1
Testing2 test2 test2
Testing 3 test3 test3
GLU900 L700/800/1800/2100/2600/2602 5G 4 Sec

//p/descendant::*/text()

FuncID

                    

                        
SiteName

                    

                        
Technology

                    

                        
Comments

                    
T223566
T335125
T311000
Testing1 test1 test1
Testing2 test2 test2
Testing 3 test3 test3
GLU900 L700/800/1800/2100/2600/2602 5G 4 Sec

Depending on which one you choose, they will return an array of values and by the looks if it, it will ignore all of the blank rows.

I tested with the second XPath query in my flow which yielded the following result ...

Result

This was the step after initializing a variable which contained your HTML data (again, removing the   values though) ...

xpath(xml(variables('XML')), '//p/descendant::*/text()')
提笔落墨 2025-02-03 23:17:18

我不擅长HTML,因此我将文件转换为PDF,并使用AI Builder读取PDF文件内容,并且对我来说很好,也许您可​​以尝试一下。

I'm not good at HTML, so I convert the file to PDF, and use AI Builder to read the PDF file content and it's working well for me, maybe you can try it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文