0

I have these HTML form in which am trying to get the input value

<form action="/checkout/cart" method="POST" class="update-qty-form">
    <div class="quantity num-selector">
        <input type="tel" value="1" name="qty" maxlength="3" class="quantity-increment">
    </div>
</form>

With the Code it doesn't work

var Quantity = items
    .Elements("form").First()
    .Elements("div").First()
    .Elements("input").First().Attributes["value"].Value;
Debug.WriteLine("The Quantity is : " + Quantity);
donkripton
  • 59
  • 1
  • 9
  • possible duplicate of [HtmlAgilityPack -- Does
    close itself for some reason?](http://stackoverflow.com/questions/4218847/htmlagilitypack-does-form-close-itself-for-some-reason)
    – Andrey Korneyev Jun 26 '15 at 08:43

1 Answers1

0

We recently used this bit of code to extract data from an attribute:

var htmlDoc = new HtmlDocument();
 htmlDoc.LoadHtml(@"<form action='/checkout/cart' method='POST' class='update-qty-form'><div class='quantity num-selector'><input type='tel' value='1' name='qty' maxlength='3' class='quantity-increment'></div></form>");


var value = htmlDoc.DocumentNode.SelectSingleNode("//input").Attributes["value"].Value;

Hope it helps

Hugh
  • 450
  • 3
  • 13