我想从li
课程中获取内文或更好的内部HTML。
在普通的桌面版中,它可以正常工作。
但是同样的代码在WP8上不起作用,因为wp8并没有所有的功能。我在整个互联网上搜索,我只找到桌面代码或代码不起作用的代码。
HtmlElement e1 = webBrowser1.Document.GetElementById(textBox2.Text);
string content = e1.InnerText;
textBox1.Text = content;
有HTML表单,我希望得到相同的结果,就像我用“桌面”版本的c#
<li id="ContentHolderMain_ContentHolderMainContent_ContentHolderMainContent_lstvAlphabet_listRestaurants_0_lstvRestaurant_0_liItem_0" class="restaurantItem" sssp:rs="2;7;8;10;" sssp:rl="Ljubljana" sssp:rn=""Celica hostel"">
<div class="name">
<h1>
<h2>(Metelkova 8, Ljubljana)</h2>
<span class="blocked"></span>
<span class="blocked"> </span>
</div>
<div class="breaker"></div>
<div class="prices">
<p>
<span>Vrednost doplacila:</span>
<strong>3,15 EUR</strong>
</p>
<p>
<span>Vrednost obroka:</span>
<strong>5,78 EUR</strong>
</p>
</div>
<div class="features">
<img id="ContentHolderMain_ContentHolderMainContent_ContentHolderMainContent_lstvAlphabet_listRestaurants_0_lstvRestaurant_0_lstvFeatures_0_imgFeature_0" title="Celiakiji prijazni obroki" alt="Celiakiji prijazni obroki" src="/App_Themes/SOS/images/icncoeliac.png">
<img id="ContentHolderMain_ContentHolderMainContent_ContentHolderMainContent_lstvAlphabet_listRestaurants_0_lstvRestaurant_0_lstvFeatures_0_imgFeature_1" title="Solatni bar" alt="Solatni bar" src="/App_Themes/SOS/images/icnsaladbar.png">
<img id="ContentHolderMain_ContentHolderMainContent_ContentHolderMainContent_lstvAlphabet_listRestaurants_0_lstvRestaurant_0_lstvFeatures_0_imgFeature_2" title="Stalen arhitektonsko prilagojen dostop za invalide in dostop do mize v notranjosti lokala ter do toalete prilagojene za invalide" alt="Stalen arhitektonsko prilagojen dostop za invalide in dostop do mize v notranjosti lokala ter do toalete prilagojene za invalide" src="/App_Themes/SOS/images/icnwheelchairwc.png">
<img id="ContentHolderMain_ContentHolderMainContent_ContentHolderMainContent_lstvAlphabet_listRestaurants_0_lstvRestaurant_0_lstvFeatures_0_imgFeature_3" title="Kosila" alt="Kosila" src="/App_Themes/SOS/images/icnlunch.png">
</div>
<div class="breaker"></div>
</li>
答案 0 :(得分:0)
您将无法使用WebBrowser控件执行此操作,但如果只需要检索HTML元素上的内容,则只需使用普通的WebRequest检索HTML,然后使用Html Agility Pack即可解析HTML。