C#通过HtmlElement访问标签属性(C# Access tags properties by HtmlElement)
有一个像:
<div id="instance" style="color:red;display:block; .... bila bila"> <h2>some text</h2> </div>
我想通过这个代码访问div的样式;
foreach (HtmlElement link in webBrowser1.Document.GetElementsByTagName("div")) { if (link.GetAttribute("id").ToString() == "instance") { MessageBox.Show(link.innerhtml); } }
但是link.innerhtml给了我div标签的内部,而不是div自己的。 Messag.Box的输出文本是:
<h2>some text</h2>
我也试过这个:
MessageBox.Show(link.GetAttribute("style"));
但它没有用。
如何通过相同div的id访问div属性?
There is an html like:
<div id="instance" style="color:red;display:block; .... bila bila"> <h2>some text</h2> </div>
I wanna access style of div via this code;
foreach (HtmlElement link in webBrowser1.Document.GetElementsByTagName("div")) { if (link.GetAttribute("id").ToString() == "instance") { MessageBox.Show(link.innerhtml); } }
But link.innerhtml gives me the inside of div tag, not div's own. Output text of Messag.Box is:
<h2>some text</h2>
I also tried this too:
MessageBox.Show(link.GetAttribute("style"));
but it didnt work.
How to access div properties via same div's id?
原文:https://stackoverflow.com/questions/21970325
最满意答案
你可能会碰到Python自己的
commands
模块(它没有类似你的子模块)的冲突 - 以隐藏标准库中的模块和包的方式命名你自己的模块和包(就像命名变量的方式一样意在隐藏内建名称,如list
或file
)始终是一项危险的工作,尽管它“应该”起作用,但始终存在混淆的可能性。你能否尝试将
commands
包及其用途重命名为明确且没有危险的内容,例如mycommands
,并查看是否会使问题消失? 如果是这种情况,你可以在GAE的跟踪器上打开一张票(因为它会在GAE的运行时显示一个小的但不可否认的错误),但同时你的问题已经解决了! - )如果问题依然存在,那么至少我们已经消除一个可能的原因,并可以继续挖掘...You could be running into a clash with Python's own
commands
module (which doesn't have submodules like yours) -- naming your own modules and packages in ways that are meant to hide ones in the standard library (just like naming your variables in ways that are meant to hide builtin names, likelist
orfile
) is always a perilous undertaking, even though it "should" work there's always potential for confusion.Could you try renaming that
commands
package and its uses to something unambiguous and free from danger, such asmycommands
, and see if that just makes the problem disappear? If that's the case you can then open a ticket on GAE's tracker (because it would show a minor but undeniable bug in GAE's runtime) but meanwhile your problem is solved!-) If the problem stays, ah well, at least we've eliminated one likely cause and can keep digging...
相关问答
更多-
这是1.5.5 SDK中的一个错误。 说明和解决方法如下: https : //groups.google.com/forum/#!topic / google-appengine-java / iKLgAzFIU_s It is a bug in the 1.5.5 SDK. Description and workaround are here: https://groups.google.com/forum/#!topic/google-appengine-java/iKLgAzFIU_s
-
如何同步Google App Engine上的数据存储?(How does one sync live to dev datastores on Google App Engine?)[2022-03-02]
有没有这样做的微不足道的方法,但有一些可能性: 如果您的应用程序使用Python(但不是Django),请使用官方批量上传器 (来自GAE-Python SDK) 如果您的应用程序在Django中,请使用Gaebar 如果您的应用程序使用Java,请使用Datanucleus REST API 您也可以尝试一些其他旨在解决此问题的开源项目。 AppRocket是一个很有前途的项目,但是项目只有一个提交者,过去几个月没有任何活动。 此外,明星问题59和776得到这个谷歌正式包括。 There's no tri ... -
当您作为HttpServlet运行时,听起来好像没有正确配置依赖项。 你如何告诉你的应用程序使用哪些依赖项? 你想加载什么版本? 该版本是否可在Google App Engine中使用? 请注意,您需要的杰克逊库的特定版本会根据您运行的环境而更改。请参阅https://developers.google.com/api-client-library/java/google-http-java-client/setup各种环境中所需的依赖项列表。 ANSWER: When working with HTTP ...
-
你有没有命名文件memcache.py? 如果是这样,删除它,也memcache.pyc。 Did you perhaps name a file memcache.py? If so remove it and also memcache.pyc.
-
你可能会碰到Python自己的commands模块(它没有类似你的子模块)的冲突 - 以隐藏标准库中的模块和包的方式命名你自己的模块和包(就像命名变量的方式一样意在隐藏内建名称,如list或file )始终是一项危险的工作,尽管它“应该”起作用,但始终存在混淆的可能性。 你能否尝试将commands包及其用途重命名为明确且没有危险的内容,例如mycommands ,并查看是否会使问题消失? 如果是这种情况,你可以在GAE的跟踪器上打开一张票(因为它会在GAE的运行时显示一个小的但不可否认的错误),但同时你的 ...
-
最近发布的Windows SDK(1.8.6)中存在一个错误。 刚刚发布了一个修复该bug的新版本(1.8.6.1)。 请尝试下载该版本。 https://developers.google.com/appengine/downloads#Google_App_Engine_SDK_for_Go There was a bug in the recently released windows SDK (1.8.6). A newer version has just been released which ...
-
Google App Engine Python的Pygments不起作用(Pygments for Google App Engine Python Doesn't Work)[2023-04-06]
您可以运行Pygments,因为它是纯Python,但它不包含在GAE中作为默认库。 相反,您需要下载源并将其复制到项目中。 转到PyPi并下载Pygments 。 解压缩,然后将源复制到项目的app引擎文件夹中 (可能最好在顶层)。 然后你可以像往常一样import pygments 。 如果要将其放在子目录(例如mypackages )中,则必须更改导入字符串,例如from mypackages import pygments 。 You can run Pygments because it's pu ... -
NoClassDefFoundError不一定是“未找到类”。 见http://javarevisited.blogspot.co.uk/2011/06/noclassdeffounderror-exception-in.html NoClassDefFoundError is not necessarily "Class not found". See http://javarevisited.blogspot.co.uk/2011/06/noclassdeffounderror-exception-in ...
-
如何在Python webapp(Google App Engine)中导入gflags?(How to import gflags in Python webapp (Google App Engine)?)[2023-08-28]
你是在正确的轨道上,但他们的python设置程序正在搞砸你; 它与GAE不兼容。 在GAE上部署应用程序时,它会将整个项目文件夹上传到GAE服务器。 您的所有库都必须位于项目文件夹中,否则在GAE服务器上运行时它们将丢失。 当您安装python库时,它通常在一个可安装的包中,包含实际的库以及一些安装程序代码,测试代码等。实际的库代码通常位于实际解压缩的子文件夹中。 运行安装程序会将库复制到您的全局python库中,这对GAE没用。 所以你需要做的是将实际的gflags库本身复制到GAE项目文件夹中。 我快速 ... -
是的,我已经在Google App Engine上实施了HikariCP,但有一些注意事项; Google App Engine使用三种类型和实例类 ; 自动缩放 基本缩放 手动缩放 只有基本和手动缩放类型允许后台线程,因此是与HikariCP一起使用的唯一候选者。 我已经使用了Basic Scaling,这对于大致已知的用户群来说没有问题(例如,每个已部署的实例都有一个公司)。 此类型还支持其他一些不错的功能,如会话支持和功能强大的B8实例(1024 MB / 4.8 GHz)。 对于我的大多数应用程序, ...