2013-07-16 39 views
0

嘿所有我有以下的HTML,我需要從文本:HTML敏捷性包發現標籤和內文

<place.tag theBID="Example of text here and there" percentage="512.6"> 
    <... other html tags here ...> 
    <longer.bid type="string"> 
     This is an example of the longer bid here and there. 
    </longer.bid> 
    <... other html tags here ...> 
</place.tag> 

這是我的VB.net代碼:

For Each listItem In doc.DocumentNode.SelectNodes("//place.tag[""longer.bid""]") 
    Debug.Print(listItem.InnerText) 
Next 

的錯誤我上( 「//place.tag[""longer.bid」 「]」)部分是:

Object reference not set to an instance of an object. 

我希望獲得文本這是一個在這裏和那裏出價較長的例子。問題是我不能使用[@ id =或甚至[@ class =以獲得自HTML中每個標記的BID更改以來的值。

任何幫助將是偉大的!

+1

爲什麼使用HTML Agility Pack解析XML而不是XML解析器? – Oded

+0

@Oded因爲它包裝在HTML中,所以它不會被認爲是XML XML解析器,因爲它不是從所需的XML屬性開始的。 – StealthRT

回答

0
For Each listItem In doc.DocumentNode.SelectNodes("//place.tag//longer.bid") 
    Debug.Print(listItem.InnerText) 
Next