Matthew The Terrible
Matthew The Terrible

Reputation: 1643

using html agility to get the value of this node

Trying to use html agility pack to get the value of the number of servings here

<span class="recipe-ingredients__header__toggles">
    <span class="ready-in-time__container">
        <span class="ready-in-time">3 h 30 m</span>
        <span class="icon--stats-clock"></span>
    </span>

<meta id="metaRecipeServings" itemprop="recipeYield" content="8">

<a href="" id="servings-button" popup-trigger="servingsSection">
    <span class="servings-count" ng-class="{'active': servingsSection_showing}"><span ng-bind="adjustedServings" class="ng-binding">8</span><span class="servings-count__desc" ng-class="{'active': servingsSection_showing}"> servings</span></span>

    <span class="icon--adjust-servings" ng-class="{'active': servingsSection_showing}"></span>
</a>

    <a href="" id="nutrition-button" popup-trigger="nutritionSection">
        <span class="calorie-count" ng-class="{'active': nutritionSection_showing}"><span>562</span> <span class="calorie-count__desc" ng-class="{'active': nutritionSection_showing}"> cals</span></span>
        <span class="icon--nutrition-info" ng-class="{'active': nutritionSection_showing}"></span>
    </a>

Specifically I'm looking at the tag

 <span ng-bind="adjustedServings">

that has the value "8". I've gotten every other value just fine here but can't seem to figure this one out. I just want the integer 8 in this case.

Upvotes: 0

Views: 149

Answers (1)

user8098743
user8098743

Reputation:

SelectSingleNode("//span[@ng-bind='adjustedServings']").InnerText

Should do the trick. If you have multiple of these spans use SelectNodes instead, use it in a foreach and access InnerText on the nodes separately.

Didn't try to compile, if you run into error, I'll edit it

Upvotes: 1

Related Questions