Home > DeveloperSection > Forums > How to get value from any tag in web browser control using wpf
Madam Walker
Madam Walker

Total Post:22

Posted on    July-15-2013 3:47 AM


 1 Reply(s)
 936  View(s)
Rate this:

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="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" />





    <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="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>


          <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="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>





    <script type="text/javascript" charset="utf-8">

        var twttr = twttr || {};

        twttr.form_authenticity_token = '015cfb03a75wdsfgdf6753dsfb0770c4dab7f3f89b';

        if (self == top) {

            document.documentElement.style.display = 'block';




    <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>










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.

shreesh chandra shukla
shreesh chandra shukla

Total Post:105

Posted on    July-15-2013 7:53 AM

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

Don't want to miss updates? Please click the below button!

Follow MindStick