如何从网页中提取元素的样式? [英] How do you extract the style of an element from a webpage?
问题描述
我正在创建一个编码的ui,我需要提取样式元素,然后在其中拉出宽度。 这将来自网页。 有什么建议吗? 我根本无法理解。
这是标签:
< li style =" width:80%;" class =" current-rating">< / li>
所以我需要输入数字80 。
提前致谢。
目前,您必须使用mshtml来验证IE的样式属性。
IHTMLElement2
element = control.NativeElementIHTMLElement2 ;
IHTMLCurrentStyle
style = element.currentStyle as
IHTMLCurrentStyle ;
您可以使用style.width获取宽度。请参阅IHTMLCurrentStyle的msdn文档
http://msdn.microsoft.com/en-us/library/aa704104(v=VS.85).aspx 获取完整列表属性。
Vinoth 跨度> 跨度> 跨度>
I am creating a coded ui which I need to extract the style element, and then within that pull the width. This will be from a webpage. Any suggestions? I can't figure it out at all.
Here is the tag:
<li style="width: 80%;" class="current-rating"></li>
So I'd need to pull in the number 80.
Thanks in advance.
Currently, you've to use mshtml to validate the style properties for IE.
IHTMLElement2 element = control.NativeElement as IHTMLElement2;
IHTMLCurrentStyle style = element.currentStyle as IHTMLCurrentStyle;
You can get the width using style.width. Please refer to msdn documentation of IHTMLCurrentStyle http://msdn.microsoft.com/en-us/library/aa704104(v=VS.85).aspx for the complete list of properties.
Vinoth.
这篇关于如何从网页中提取元素的样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!