我正在为报告的工作询问,该报告编写了一些书写的HTML代码,其中只有一些标签具有我可以用于创建列的CSS选择器,但其他标签则没有。 (猜猜是谁写的?)我使用nth-child编写了一些解决方法,并将每个步骤描述为所需的选项卡,但是,如所期望的那样,当对所有其他报告扩展时会引起问题,因为并非每个桌子都与所包含的内容相似。
我的工作代码:
{"Rule ID", "td[class='rule-id']"}
但是,下一列我使用了以下内容:
{"Time", "div[class='panel-body'] > TABLE > TBODY > TR:nth-child(6) > TD:nth-child(2)"}
哪些表中确实会抓住时间,但是在其他表中,它抓住了错误的标签。我想知道是否有一种方法可以参考标签之间的信息。时间代码看起来像这样:
<table>
...
<tr>
<td>Time</td>
<td>2022-04-28T10:01:15+00:00</td>
</tr>
...
</table>
我尝试过,但是它导致了100%空的列:
{"Time", "td[contains='Time']"}
这是我的第一个项目,所以我在学习时学习,并通过Google找到了大多数问题的答案,但我无法``这个问题都相当短,以找到一个很好的结果。所有代码都在我的GFE上,因此我无法在这里分享,希望我可以分享的位已经足够了。
预先感谢您的帮助!
I am writing a query for work for a report that has some poorly written HTML code where only some of the tags have a CSS selector I can use for creating my columns but others don't. (Guess who wrote it?) I wrote some workarounds using nth-child and describing each step to the desired tab but, as expected, when scaled up to all the other reports it causes issues because not every table is alike with what it contains.
My working code:
{"Rule ID", "td[class='rule-id']"}
However the next column I used this:
{"Time", "div[class='panel-body'] > TABLE > TBODY > TR:nth-child(6) > TD:nth-child(2)"}
Which in some of the tables does grab the time, but in others it grabs the wrong tag. I'm wondering if there's a way I can refer to the information in-between the tags. The time code looks like this:
<table>
...
<tr>
<td>Time</td>
<td>2022-04-28T10:01:15+00:00</td>
</tr>
...
</table>
I tried this but it results in a 100% empty column:
{"Time", "td[contains='Time']"}
This is my first project in Power BI so I'm learning as I go and have found answers to most of my questions through Google but I couldn't quite phrase this question properly to find a good result. All of the code is on my GFE so I can't get it over here to share, hopefully the bits I could share are enough.
Thank you in advance for your help!
发布评论
评论(1)
如果您链接该网站,我可以给出更好的答案。
有一个可选的第三参数,可让您更多地访问属性。
{“ name”,“ selector”}
将成为{“ name”,“ selector”,每个_}
,ex:selector
这不是在寻找您的HTML,它将与此匹配。这是一个很好的参考/作弊表
在Web控制台中的浏览器中测试选择器
,您可以使用CSS选择器查询来预览将选择的CSS选择器查询。
Firefox使用函数
$
和$$
具有速记。否则使用document.queryselector()
和document.queryselectorall()
您的
rowselector
如果要使用
$$(”表。 ;
table& gt img src =“ https://i.sstatic.net/2vwzs.png” alt =“ Horizontal-preview”>
您的
colugn> colugnnameselectorpairs
,然后
table.table.table.table&gt; *&gt; tr&gt; :nth-child(1)
来自:
If you link the site I can give a better answer.
There's an optional 3rd parameter, that gives you more access to attributes.
{"Name", "Selector"}
would become{"Name", "Selector", each _ }
, ex:selector
This isn't looking for what your html, it would match this. Here's a good reference/cheatsheet
Testing Selectors in a browser
In the web console, you can use a CSS Selector query to preview what it will select.
Firefox has shorthand using the function
$
and$$
. otherwise usedocument.querySelector()
anddocument.querySelectorAll()
Your
RowSelector
If you were to use
$$("TABLE.table > * > TR")
as yourRowSelector
Your
columnNameSelectorPairs
And then
TABLE.table > * > TR > :nth-child(1)
From: