help files
Z505 | PasWiki | FUQ | Search | Main Docs | API Guide



[Overview][Procedures and functions] Reference for unit 'HTMLUtil' (#powtils_main_html)

GetVal

Declaration

Source position: htmlutil.pas line 15

function GetVal(

  const tag: String;

  const attribname_ci: String

):String;

Notes

Returns the VALUE portion of a NAME/VALUE pair in a html tag. You specify the attribute (name portion). Therefore the name portion is case insensitive, but the value portion returned has case preserved.

(For example you want to preserve the url case on unix servers but hReF or HrEf or HREF or href you do not want to preserve. This function therefore is perfect for all case issues you might be worried about.)

The GetVal function even parses non-strict or sloppy html name value pairs with any sort of quotes or lack of quotes:

  name=val, 
  something='value', 
  nAmE="other"

Example

var
  s: string;
begin
  s:= htmlutil.GetVal('<a href="http://url.com">link</a>', 'href');
  writeln(s); 
  s:= htmlutil.GetVal('<font color="red">text</font>', 'color');
  writeln(s); 

end;
Program outputs:
   http://url.com
   red





lufdoc, Powtils, fpc, freepascal, delphi, kylix, c/c++, mysql, cgi web framework docs, Z505