Mega Code Archive

 
Categories / C# / Network
 

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