2012-05-04 56 views
0

我有div元素文本中嵌套的div的div htmlagilitypack

<div title="View this search: Actives"> 
<div style="float:right;"> 
<span class="count" title="some title" id="search_201204"> 
34 New or Changed 
</span> 
<span id="trash_2012">&nbsp;&nbsp;X</span> 
</div> 
The value i need 
<div style="padding-left:20px;color:#888"></div> 
</div> 

我需要得到与标题外div的的innerText包含some title

我有这样的代码

divs = docNode.SelectNodes("//div[contains(@title, 'View this search:')]") 
If divs Is Nothing Then Continue For 
For Each div In divs 
    If div Is Nothing Then Continue For 
    If ListSearch.Contains(div.InnerText) = False Then 
     ListSearch.Add(div.InnerText) 
    End If 
Next 

这给了我

34新增功能或变更    XThe值,我需要

,而不是

我需要的价值

这是外部div的文本。

请提供您拥有的任何解决方案。

感谢

回答

1

尝试使用以下XPath:

//div[contains(@title, 'View this search:')]/child::text()/following-sibling::text() 
+0

非常感谢。你是否在构建这个声明时使用了任何工具,或者你是如何弄清楚的? – Smith

+0

没有工具,只是xpath文档)) – Mike

+0

请你能给我这个文档?再次感谢 – Smith