Skip to main content

Removing HTML Tags from string in C#

Hello friends, With this very first post of our new Blog GimiBits, we start our whole new journey contributing to information technology.
Our First post is about the logic to remove the HTML tags from the given string with C# (C Sharp) programming language. Logic is very Simple to Implement, we take up a string and for its each index char we find the opening '<' braces and ignores the inside content until the closing '>' braces is not encountered and save to another char[] datatype.

Here is a function based Implementation of the logic:

 public string RemoveHtmlTags(string Html)
        {
            string content = Html;
            char[] array = new char[content.Length];
            int arrayIndex = 0;
            bool inside = false;

            for (int i = 0; i < content.Length; i++)
            {
                char let = content[i];
                if (let == '<')
                {
                    inside = true;
                    continue;
                }
                if (let == '>')
                {
                    inside = false;
                    continue;
                }
                if (!inside)
                {
                    array[arrayIndex] = let;
                    arrayIndex++;
                }
            }
            return new string(array, 0, arrayIndex);
        }
Post any problems encountered in the comments. Thanks for visiting GimiBits.
Please Share this post and like us on Facebook.

All Regards,
Jaskaran SH SD
Editor in Chief

Comments

Popular posts from this blog

List Of Most Searched Topics On Google 2016

List Of Most Searched Topics On Google                                                                                                                               source Global Searches   1) Pokémon Go  2) iPhone 7   3) Donald Trump   4) Prince   5) Powerball   6) David Bowie   7) Deadpool   8) Olympics   9) Slither.io  1 0) Suicide Squad Global News   1) US Election  2) Olympics   3) Brexit   4) Orlando Shooting  5) Zika Virus   6) Panama Papers  7) Nice 8) Brussels  9) Dallas Shooting  10) 熊本 地震 ( Kumamoto Earthquake) People   1) Donald Trump   2) Hillary Clinton   3) Michael Phelps   4) Melania Trump   5) Simone Biles   6) Bernie Sanders   7) Steven Avery   8) Céline Dion   9) Ryan Lochte  10) Tom Hiddleston Consumer Tech   1) iPhone 7   2) Freedom 251   3) iPhone SE   4) iPhone 6S   5) Google Pixel   6) Samsung Galaxy S7   7) iPhone 7 Plus   8) Note 7   9) Nintendo Switch  10) Samsung J7 Global Sporting Events   1) Rio O

THE BEST BRAIN TRAINING APPS FOR ANDROID

THE BEST BRAIN TRAINING APPS FOR ANDROID Elevate - Brain Training Elevate is a brain training program designed to improve attention, speaking skills, processing speed, memory, math skills, and more. Each person is provided with his or her own personalized training program that adjusts over time to maximize results. The more you train with Elevate, the more you’ll improve critical cognitive skills that are designed to boost productivity, earning power, and self-confidence. Users who train at least 3 times per week have reported dramatic gains and increased confidence. FEATURES * 35+ brain games for critical cognitive skills like focus, memory, processing, math, precision, and comprehension * Detailed performance tracking * Personalized daily workouts that include the skills you need most * Adaptive difficulty progression to ensure your experience is challenging * Workout calendar to help you track your streaks and stay motivated Peak - Brain Training P

Introduction to Programming language C

Dennis Ritchie ( US) designed C programming language in 1972 at "AT & T's Bell laboratories". C has been often termed as " M iddle Leve l Language " . Programs written in C are very efficient and fast. C is a general purpose structured powerful language. Features at a Glance: • C is highly portable language .This means that a C program written for one system can be run on another system with little or no modifications. • C's another striking feature is its ability to extend itself. We can add our own functions to the C library . • Writing a C program with user defined makes program more simple and easy to understand . • C - language has more data types ( except boolean operators ), operators and can take more variables than other languages. • C - language is a structured programming language that is  it has different modules and blocks . • C - language is used to develop graphics software . 2D and 3D graphics are also implemented using C.