home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd1.bin / zkuste / Perl / ActivePerl-5.6.0.613.msi / 䆊䌷䈹䈙䏵-䞅䞆䞀㡆䞃䄦䠥 / _91243be75c42fedadef2ca7541187083 < prev    next >
Text File  |  2000-03-23  |  6KB  |  153 lines

  1.  
  2. <HTML>
  3. <HEAD>
  4. <TITLE>HTML::HeadParser - Parse <HEAD> section of a HTML document</TITLE>
  5. <LINK REL="stylesheet" HREF="../../../Active.css" TYPE="text/css">
  6. <LINK REV="made" HREF="mailto:">
  7. </HEAD>
  8.  
  9. <BODY>
  10. <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
  11. <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
  12. <STRONG><P CLASS=block> HTML::HeadParser - Parse <HEAD> section of a HTML document</P></STRONG>
  13. </TD></TR>
  14. </TABLE>
  15.  
  16. <A NAME="__index__"></A>
  17. <!-- INDEX BEGIN -->
  18.  
  19. <UL>
  20.  
  21.     <LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
  22.  
  23.     <LI><A HREF="#synopsis">SYNOPSIS</A></LI>
  24.     <LI><A HREF="#description">DESCRIPTION</A></LI>
  25.     <LI><A HREF="#methods">METHODS</A></LI>
  26.     <LI><A HREF="#example">EXAMPLE</A></LI>
  27.     <LI><A HREF="#see also">SEE ALSO</A></LI>
  28.     <LI><A HREF="#copyright">COPYRIGHT</A></LI>
  29. </UL>
  30. <!-- INDEX END -->
  31.  
  32. <HR>
  33. <P>
  34. <H1><A NAME="name">NAME</A></H1>
  35. <P>HTML::HeadParser - Parse <HEAD> section of a HTML document</P>
  36. <P>
  37. <HR>
  38. <H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
  39. <UL>
  40. <LI>Linux</LI>
  41. <LI>Solaris</LI>
  42. <LI>Windows</LI>
  43. </UL>
  44. <HR>
  45. <H1><A NAME="synopsis">SYNOPSIS</A></H1>
  46. <PRE>
  47.  require HTML::HeadParser;
  48.  $p = HTML::HeadParser->new;
  49.  $p->parse($text) and  print "not finished";</PRE>
  50. <PRE>
  51.  $p->header('Title')          # to access <title>....</title>
  52.  $p->header('Content-Base')   # to access <base href="<A HREF="http://..."">http://..."</A>;>
  53.  $p->header('Foo')            # to access <meta http-equiv="Foo" content="..."></PRE>
  54. <P>
  55. <HR>
  56. <H1><A NAME="description">DESCRIPTION</A></H1>
  57. <P>The <EM>HTML::HeadParser</EM> is a specialized (and lightweight)
  58. <EM>HTML::Parser</EM> that will only parse the <HEAD>...</HEAD>
  59. section of an HTML document.  The <A HREF="#item_parse"><CODE>parse()</CODE></A> method
  60. will return a FALSE value as soon as some <BODY> element or body
  61. text are found, and should not be called again after this.</P>
  62. <P>The <EM>HTML::HeadParser</EM> keeps a reference to a header object, and the
  63. parser will update this header object as the various elements of the
  64. <HEAD> section of the HTML document are recognized.  The following
  65. header fields are affected:</P>
  66. <DL>
  67. <DT><STRONG><A NAME="item_Content%2DBase%3A">Content-Base:</A></STRONG><BR>
  68. <DD>
  69. The <EM>Content-Base</EM> header is initialized from the <base
  70. href=``...''> element.
  71. <P></P>
  72. <DT><STRONG><A NAME="item_Title%3A">Title:</A></STRONG><BR>
  73. <DD>
  74. The <EM>Title</EM> header is initialized from the <title>...</title>
  75. element.
  76. <P></P>
  77. <DT><STRONG><A NAME="item_Isindex%3A">Isindex:</A></STRONG><BR>
  78. <DD>
  79. The <EM>Isindex</EM> header will be added if there is a <isindex>
  80. element in the <head>.  The header value is initialized from the
  81. <EM>prompt</EM> attribute if it is present.  If not <EM>prompt</EM> attribute is
  82. given it will have '?' as the value.
  83. <P></P>
  84. <DT><STRONG><A NAME="item_X%2DMeta%2DFoo%3A">X-Meta-Foo:</A></STRONG><BR>
  85. <DD>
  86. All <meta> elements will initialize headers with the prefix
  87. ``<CODE>X-Meta-</CODE>'' on the name.  If the <meta> element contains a
  88. <CODE>http-equiv</CODE> attribute, then it will be honored as the header name.
  89. <P></P></DL>
  90. <P>
  91. <HR>
  92. <H1><A NAME="methods">METHODS</A></H1>
  93. <P>The following methods (in addition to those provided by the
  94. superclass) are available:</P>
  95. <DL>
  96. <DT><STRONG><A NAME="item_new">$hp = HTML::HeadParser->new( [$header] )</A></STRONG><BR>
  97. <DD>
  98. The object constructor.  The optional $header argument should be a
  99. reference to an object that implement the <A HREF="#item_header"><CODE>header()</CODE></A> and <CODE>push_header()</CODE>
  100. methods as defined by the <EM>HTTP::Headers</EM> class.  Normally it will be
  101. of some class that isa or delegates to the <EM>HTTP::Headers</EM> class.
  102. <P>If no $header is given <EM>HTML::HeadParser</EM> will create an
  103. <EM>HTTP::Header</EM> object by itself (initially empty).</P>
  104. <P></P>
  105. <DT><STRONG><A NAME="item_parse">$hp->parse( $text )</A></STRONG><BR>
  106. <DD>
  107. Parses some HTML text (see HTML::Parser-><A HREF="#item_parse"><CODE>parse())</CODE></A> but will return
  108. FALSE as soon as parsing should end.
  109. <P></P>
  110. <DT><STRONG><A NAME="item_header">$hp->header;</A></STRONG><BR>
  111. <DD>
  112. Returns a reference to the header object.
  113. <P></P>
  114. <DT><STRONG>$hp->header( $key )</STRONG><BR>
  115. <DD>
  116. Returns a header value.  It is just a shorter way to write
  117. <A HREF="#item_header"><CODE>$hp->header->header($key)</CODE></A>.
  118. <P></P></DL>
  119. <P>
  120. <HR>
  121. <H1><A NAME="example">EXAMPLE</A></H1>
  122. <PRE>
  123.  $h = HTTP::Headers->new;
  124.  $p = HTML::HeadParser->new($h);
  125.  $p->parse(<<EOT);
  126.  <title>Stupid example</title>
  127.  <base href="<A HREF="http://www.sn.no/libwww-perl/"">http://www.sn.no/libwww-perl/"</A>;>
  128.  Normal text starts here.
  129.  EOT
  130.  undef $p;
  131.  print $h->title;   # should print "Stupid example"</PRE>
  132. <P>
  133. <HR>
  134. <H1><A NAME="see also">SEE ALSO</A></H1>
  135. <P><A HREF="../../../site/lib/HTML/Parser.html">the HTML::Parser manpage</A>, <A HREF="../../../site/lib/HTTP/Headers.html">the HTTP::Headers manpage</A></P>
  136. <P>The <EM>HTTP::Headers</EM> class is distributed as part of the <EM>libwww-perl</EM>
  137. package.</P>
  138. <P>
  139. <HR>
  140. <H1><A NAME="copyright">COPYRIGHT</A></H1>
  141. <P>Copyright 1996-1998 Gisle Aas. All rights reserved.</P>
  142. <P>This library is free software; you can redistribute it and/or
  143. modify it under the same terms as Perl itself.</P>
  144. <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
  145. <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
  146. <STRONG><P CLASS=block> HTML::HeadParser - Parse <HEAD> section of a HTML document</P></STRONG>
  147. </TD></TR>
  148. </TABLE>
  149.  
  150. </BODY>
  151.  
  152. </HTML>
  153.