<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          Streaming HTML parser

          聯(lián)合創(chuàng)作 · 2023-09-22 00:14

          Streaming HTML parser 是一個(gè) C 語言的 HTML 解析器。

          示例代碼

          #include <stdio.h>
          #include <streamhtmlparser/htmlparser.h>

          int main(void) {
           
          unsigned int getchar_ret;
            htmlparser_ctx
          *parser = htmlparser_new();

           
          while((getchar_ret = getchar()) != EOF) {
             
          char c = (char)getchar_ret;

             
          /* If we received a '$' character, we output the current tag and attribute
               * name to stdout. */

             
          if (c == '$') {
                printf
          ("[[ ");
               
          if (htmlparser_tag(parser))
                  printf
          ("tag=%s ", htmlparser_tag(parser));
               
          if (htmlparser_attr(parser))
                  printf
          ("attr=%s ", htmlparser_attr(parser));
                printf
          ("]]");

             
          /* If we read any other character, we pass it to the parser and echo it to
               * stdout. */

             
          } else {
                htmlparser_parse_chr
          (parser, c);
                putchar
          (c);
             
          }
           
          }
          }

          輸入

          <html>   <body $>     <title> $ </title>     <a href="$" alt="$"> url </a>   </body> </html>

          輸出

          <html>   <body [[ tag=body ]]>     <title> [[ tag=title ]] </title>     <a href="[[ tag=a attr=href ]]" alt="[[ tag=a attr=alt ]]"> url </a>   </body> </html>

           

          瀏覽 9
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          評論
          圖片
          表情
          推薦
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  字幕一区二区三区四区五区在线看 | 欧美乱码精品一区二区三区 | 日日爱69| 国产又黄网站 | 免费黄片视频在线观看 |