---
title: "How to get value from any tag in web browser control using wpf"  
description: "How to get value from any tag in web browser control using wpf"  
author: "Madam Walker"  
published: 2013-07-15  
updated: 2026-05-15  
canonical: https://www.mindstick.com/forum/1280/how-to-get-value-from-any-tag-in-web-browser-control-using-wpf  
category: "wpf"  
tags: ["wpf"]  
reading_time: 2 minutes  

---

# How to get value from any tag in web browser control using wpf

I have a whole [web page](https://www.mindstick.com/forum/718/sql-server-report-alignment-to-center-of-web-page) [source code](https://www.mindstick.com/forum/33476/pls-send-me-source-code-for-changing-passward-in-asp-dot-net-i-tried-so-much-from-google-but-its-not-workining) in a [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) type variable.

These code is given below:-

```
<!DOCTYPE html><html lang="en" dir="ltr"      class="">  <head>    <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="https://abs.twimg.com/a/1373417125/tfw/css/tfw.bundle.css" media="screen" rel="stylesheet" type="text/css" />    <!--[if (IEMobile) & (lt IE 9)]>    <link href="https://abs.twimg.com/a/1373417125/tfw/css/tfw_iemobile.bundle.css" media="screen" rel="stylesheet" type="text/css" />    <![endif]-->       <style type="text/css">      html { display:none; }    </style>    <noscript>      <style type="text/css">        html { display: block; }      </style>    </noscript>    <!--[if IEMobile & lt IE 9]>    <style type="text/css">      html { display: block; }    </style>    <![endif]-->  </head>  <body class="oauth write signed-in tfw en logged-in   noloki">     <div id="header" role="banner">      <div class="bar">        <h1 class="logo"><a href="https://twitter.com/home" class="alternate-context">Twitter</a></h1>          <div id="session" role="navigation">          <h2 class="current-user"><a href="https://twitter.com/xyz" title="Ankita Kumar">            <img src="https://twimg0-a.akamaihd.net/profile_images/37880007865454313/7c577aeb3085dasf355dgf76f043c1cd09_mini.jpeg" alt="" width="24" height="24">            <span class="name">ankita_yahoo</span>          </a></h2>          <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">                </form></li>             </ul>          </div>        </div>       </div>    </div>     <div id="bd" role="main"> <p class="action-information">You've granted access to ThisTweetControl!</p> <div id="oauth_pin">  <p>    <span id="code-desc">Next, return this PIN to complete the authorization process:</span>    <kbd aria-labelledby="code-desc"><code>6107346</code></kbd>  </p></div>       </div>        <div class="footer" role="navigation"><div id="ft">   <a href="https://twitter.com/home" class="return-link alternate-context">Go to Twitter</a>   <a href="http://www.xyz.biz" 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="https://twitter.com/settings/applications">Applications tab</a> of your Settings page.</p><p><small>By authorizing an application you continue to operate under <a href="https://twitter.com/tos">Twitter's Terms of Service</a>. In particular, some usage information will be shared back with Twitter. For more, see our <a href="https://twitter.com/privacy">Privacy Policy</a>.</small></p>     </div></div>      <script type="text/javascript" charset="utf-8">        var twttr = twttr || {};        twttr.form_authenticity_token = '015cfb03a75wdsfgdf6753dsfb0770c4dab7f3f89b';        if (self == top) {            document.documentElement.style.display = 'block';        }    </script>     <script src="https://abs.twimg.com/a/14353417125/javascripts/loadrunner.js" data-main="tfw/intents/main" data-path="https://abs.twimg.com/a/1373417125/javascripts/modules" type="text/javascript"></script>         </body></html>
```

In above line of code have a code tag <code>6107346</code> with some [value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages) and I need to get the numeric value in a variable.

thanks in advanced.

## Replies

### Reply by shreesh chandra shukla

Hey [Madam Walker](http://www.mindstick.com/mindForum/ThreadList.aspx?uid=704) ! If you use System.Windows.Controls.WebBrowser control then this should work, however it works on assumption that you only have one [CODE](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) tag: var myTagValue = (wbBrowser.Document as mshtml.HTMLDocument) .getElementsByTagName("CODE") .OfType<mshtml.IHTMLElement>() .First() .innerText 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 \


---

Original Source: https://www.mindstick.com/forum/1280/how-to-get-value-from-any-tag-in-web-browser-control-using-wpf

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
