views:

42

answers:

1

I am using "HtmlAgilityPack" to parse HTML content. My target is to get number value.

<div>
    some content 1
    <br>
    some <b>content</b> 2
    <br>
    <b>NUMBER:</b>
    9788492688647
    <br>
    some content 3
    <br>
    some content 4
    </div>


aim:
 - get "9788492688647"

Anybody can tell me how to get value between  /div/b[2] and <br> ?
+2  A: 

This should work:

/div/b[2]/following-sibling::text()[1]

However, depending on how consistent the structure is, you might want to do something like:

/div/b[. = 'NUMBER:']/following-sibling::text()[1]
James Sulak
Not to forget that the returned text node value needs to be trimmed, as it still contains all leading and trailing whitespace.
Tomalak
The first one works perfectly :), the second one throw exception incorrect syntax.Great thanks :), that is what i was looking for.
czesio