Parses the value information from any INPUT tag in an HTML string where the name="" attribute matched the tagID parameter : HTML « Network « C# / C Sharp






Parses the value information from any INPUT tag in an HTML string where the name="" attribute matched the tagID parameter

 
        
//**************************************************************
//
// MoneyBaby Project - Open source payment processors for .NET
//
// Copyright 2007-2008 Marcus McConnell and BV Software
// www.CodePlex.com/MoneyBaby
//**************************************************************

using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Net;
using System.IO;

namespace BVSoftware.MoneyBaby
{
    public class Utilities
    {

        // Parse Html Tag Function
        // 
        // Parses the value information from any INPUT tag in an HTML string where the name="" attribute 
        // matched the tagID parameter
        //
        // 1/12/2005, mmcconnell1618
        public static string GetInputTagValueFromtHtmlString(string source, string tagID)
        {
            string result = string.Empty;
            string[] tags = source.Split('<');

            foreach (string tag in tags)
            {
                if (tag.Contains(">"))
                {
                    if (tag.ToLower().StartsWith("input "))
                    {
                        if (tag.ToLower().Contains("name=\"" + tagID.ToLower() + "\""))
                        {
                            int valueLocation = tag.ToLower().IndexOf("value=\"");
                            if (valueLocation >= 0)
                            {
                                char[] chars = tag.ToCharArray(0, tag.Length);
                                for (int j = valueLocation + 7; j < chars.Length - 1; j++)
                                {
                                    if (chars[j] != '"')
                                    {
                                        result += chars[j];
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return result;
        }

    }
}

   
  








Related examples in the same category

1.Get Links From HTML
2.Html Utilities
3.Convert HTML To Text
4.Converts a FontUnit to a size for the HTML FONT tag
5.Strip HTML
6.Remove tags from a html string
7.Sanitize any potentially dangerous tags from the provided raw HTML input using a whitelist based approach
8.Get Type As Html
9.HTML-encodes a string and returns the encoded string.
10.Strips all HTML tags from the specified string.
11.Removes the HTML whitespace.
12.Array To Html Breaked String
13.Show Html Page in String with Process