How to get value from any tag in web browser control using wpf

Total Post:70


 6233  View(s)
Rate this:
HI Developers!

I have a whole web page source code in a string type variable.

These code is given below:-

<!DOCTYPE html>
<html lang="en" dir="ltr"
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">
    <title>Twitter / Authorize an application</title>
    <link href="" media="screen" rel="stylesheet" type="text/css" />
    <!--[if (IEMobile) & (lt IE 9)]>
    <link href="" media="screen" rel="stylesheet" type="text/css" />
    <style type="text/css">
      html { display:none; }
      <style type="text/css">
        html { display: block; }
    <!--[if IEMobile & lt IE 9]>
    <style type="text/css">
      html { display: block; }
  <body class="oauth
    <div id="header" role="banner">
      <div class="bar">
        <h1 class="logo"><a href="" class="alternate-context">Twitter</a></h1>
        <div id="session" role="navigation">
          <h2 class="current-user"><a href="" title="Ankita Kumar">
            <img src="" alt="" width="24" height="24">
            <span class="name">ankita_yahoo</span>
          <div class="user-menu">
            <h3 class="session">User Management</h3>
            <ul class="session">
              <li class="new"><a href="/intent/tweet">New Tweet</a></li>
              <li class="settings"><a href="/settings">Settings</a></li>
              <li class="help"><a href="/help">Help</a></li>
                <li class="signout"><form action="/intent/session" method="post"><div style="margin:0;padding:0"><input name="_method" type="hidden" value="delete" /><input name="authenticity_token" type="hidden" value="015cfb030df22330e517d50b0770c4dab7f3f89b" /></div>
                    <input id="referer" name="referer" type="hidden" value="/oauth/authorize" />
                    <input type="submit" class="textual link" value="Sign out">
    <div id="bd" role="main">
<p class="action-information">You've granted access to ThisTweetControl!</p>
<div id="oauth_pin">
    <span id="code-desc">Next, return this PIN to complete the authorization process:</span>
    <kbd aria-labelledby="code-desc"><code>6107346</code></kbd>
    <div class="footer" role="navigation"><div id="ft">
  <a href="" class="return-link alternate-context">Go to Twitter</a>
  <a href="" class="supplemental-link alternate-context">Go to the ThisTweetControl homepage</a>
<p class="tip">You can revoke access to any application at any time from the <a href="">Applications tab</a> of your Settings page.</p>
<p><small>By authorizing an application you continue to operate under <a href="">Twitter's Terms of Service</a>. In particular, some usage information will be shared back with Twitter. For more, see our <a href="">Privacy Policy</a>.</small></p>
    <script type="text/javascript" charset="utf-8">
        var twttr = twttr || {};
        twttr.form_authenticity_token = '015cfb03a75wdsfgdf6753dsfb0770c4dab7f3f89b';
        if (self == top) {
   = 'block';
    <script src="" data-main="tfw/intents/main" data-path="" type="text/javascript"></script>

In above line of code have a code tag <code>6107346</code> with some value and I need to get the numeric value in a variable.

thanks in advanced.

  1. Re: How to get value from any tag in web browser control using wpf

    Hello Samuel!

    If you use System.Windows.Controls.WebBrowser control then this should work, however it works on assumption that you only have one CODE tag:

    var myTagValue = (wbBrowser.Document as mshtml.HTMLDocument)

    You'll need to reference Internet Explorer's COM library: Microsoft HTML Object Library. getElementsByTagName returns you list of all matching tags, no matter where they are in HTML

      Modified On Mar-30-2018 05:07:32 AM


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.