최신 웹 개발 튜토리얼
 

PHP xml_get_current_line_number() Function


<전체 PHP의 XML 참조

정의 및 사용

xml_get_current_line_number() 함수는 XML 파서의 현재 행 번호를 가져옵니다.

이 함수는 현재 라인의 성공에 번호 또는 실패 FALSE를 반환합니다.

통사론

xml_get_current_line_number(parser)

매개 변수 기술
parser 필요합니다. 사용하는 XML 파서를 지정합니다

<?php
//invalid xml file
$xmlfile = 'test.xml';

$xmlparser = xml_parser_create();

// open a file and read data
$fp = fopen($xmlfile, 'r');
while ($xmldata = fread($fp, 4096))
  {
  // parse the data chunk
  if (!xml_parse($xmlparser,$xmldata,feof($fp)))
    {
    die( print "ERROR: "
    . xml_error_string(xml_get_error_code($xmlparser))
    . "<br />"
    . "Line: "
    . xml_get_current_line_number($xmlparser)
    . "<br />"
    . "Column: "
    . xml_get_current_column_number($xmlparser)
    . "<br />");
    }
  }

xml_parser_free($xmlparser);
?>

코드의 출력은 위의 수 :

ERROR: Mismatched tag
Line: 5
Column: 41

<전체 PHP의 XML 참조