讓咱們望一下現實處置這個文檔的PHP代碼。
  /*NewsBoy : News system for the web writte頭。”n in PHP by Justin 公司登記Grant (Web: jusgrant.cjb.net or justin.host.za.net Mail: justin@glendale.net)25 March V0.0.2 Conve公司註冊rted Newsboy to a PHP class, allow公司登記地址ing the layout to be easily modified. Also added made the HTML that is genrated a little easier to read.24 March V0.0.1 Just completed the intial version, very rough and basic.*/
  class newsboy { var $xml_parser; var $xml_file; var $html; var $open_tag ; 地址出租var $close_tag ;
  //Class Constructor
  function newsboy() { $this-xml_parser = “”; $this-xml_公司登記file = “”; $this-html = “”; $this-open_tag = array(
  //these are the default settings but they are quite easy to modify
  ”NEWSBOY” = “nn”, “STORY” = ” “, “DATE” = “”, “SLUG” = ” “, “TEXT” = “”, “PIC” = “”, “NEWLINE” = “” ); $this-close_tag = 工商登記地址array( “NEWSBOY” = “
  nnn”, “STORY” = “”, “DATE” = “”, “SLUG” = “
  ”, “TEXT” = “n”, 營業登“媳婦!”記地址“PIC” = ” “
  ” ); }
  //Class Destructor (has to be invoked manually as PHP does not support dest公司登記地址ructors)

  function 工商登記destroy() { xml_parser_free($this-xml_parser); }
  //Class Members
  function concat($str) { $this-ht設立登記ml .= $str; }
  functi註冊地址on startElement($parser, $name, $attrs) { //global $open_tag; if (公司註冊$format= $this-open_tag[$name]) { $this-html .= $format; } 營業註冊地址}
  function e公司登記地址ndElement($parser, $name) { global $close_tag; if ($format= $this-close_tag[$name]) { $this-html .= $format; } }
  function characterData($parser, $data) { $this-html .= $data; }
  /註冊地址* function PIHandler($parser, $target, $data) { //switch (strtolower($target)){ // case “php”: eva商業登記l($data); // break; //設立登記} }*/
  function parse() { $t營業地址his-xml_parser = xml_parser_create(); xml_set_object($this-xml_parser, &$公司登記地址this); // use case-folding so we are sure to find the tag in $map_array
  xml_parser_set_option($this-xml_parser, XML_OPTION_CASE_FOLDING, true); xml_set_element_handler($this-xml_parser, “startElement”, “endElement”); xml_set_character_data_handler($this-xml_parser, “characterData”);//xml_set_processing_instruction_handler($thi商業登記s-xml_parser, “PIHandler”);
  if (!($fp = fopen($this-xml_file, “r”))) { die(“could not open XML input”); } while ($data = fread($fp, 4096)) { if (!xml_parse($this-設立公司xml_parser, $data, feof($fp))) { die(sprintf(“XML error: %s at line %d”, xml_error_string(xml_get_error_code($this-xml_parser)), xml_get公司註冊_current_line_number($this-xml_parser))); } } }}
  ?

  ——————————————————————————–

  在這個類的結構函數中,我創立瞭設立登記關上與關閉兩個標誌數組。數組商業登記的樞紐字與我前面將要剖析的標誌是
  一樣的,而且它們響應的值包括格局化關上與關閉標誌的HTML代碼。

  我界說瞭一個簡樸的類析構函數用來當咱們不再需求它時開釋XML 剖析器。這個函數不得不手工挪用,
  由於PHP不支撐當一個對象開釋時主動挪用類的析構函數。

  然後我界說瞭在XML文檔頂用來剖析關上和關閉標誌的主歸調方式。我也界說瞭一個數據剖析方式, 將
  用於當關上和關閉標誌中無數據時,對數據入行簡樸的格局化,前面我將向你演示怎樣將這些歸調方式註冊
  到剖析器中。

  在startElement和closeElement(當剖析到一個關上或關閉標專時被分離挪用)中運用 標誌的名字
  作為索引鍵值對響應的數組入行查問。假如阿誰鍵值存在商業登記地址,則返歸值而且追加到類的’html’ 屬性的前面。
  ’html’屬性將在當前咱“可見你有多不聽話,七歲就知道惹媽媽生氣!”裴母一怔。們真正顯示文檔內在的事務的時辰運用。

  characterData方式簡樸地將標誌之間的值加到類的html屬性的前面。

  被正文起來的設立公司鳴PIHandler的方式是一設立登記個歸調函數,我還不曾完成它。假如它存在的話,它將間接在XML文檔中

  轉錄發載地址:http://www.itxdl.cn/html/2017/phpnews_0424/298.html

公司地址

註冊公司

打賞

0
點贊
公司登記

主帖得到的海角分:0
“一家人是不對的,藍大人為什麼要把獨生女嫁給巴爾?他這樣做有什麼目的嗎?巴爾實在想不通。”裴毅眉頭緊鎖說道。工商登記
設立登記

公司註冊 舉報 |

樓主
| 埋紅包

By admin

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *