최신 웹 개발 튜토리얼
 

PHP xml_error_string() Function


<전체 PHP의 XML 참조

정의 및 사용

xml_error_string() 함수는 XML 파서 오류 설명을 가져옵니다.

이 기능은 실패 오류 성공에 대한 설명 또는 FALSE를 반환합니다.

통사론

xml_error_string(errorcode)

매개 변수 기술
errorcode 필요합니다. 사용하는 오류 코드를 지정합니다. 오류 코드는 반환 값이다 xml_get_error_code() 함수

<?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 참조