xml_get_error_code
XMLパーサーエラーコードを取得します
xml_get_error_code()
関数XMLパーサーのエラーコードを返します。
エラーが発生したら、XMLパーサーのエラーコード、行番号、および列番号を返します。
<?php //無効なXMLファイル $ xmlfile = 'test.xml' ; $ xmlparser = xml_parser_create ( ) ; //ファイルを開き、データを読み取ります $ fp = fopen ( $ xmlfile 、 'r' ) ; while ( $ xmldata = fread ( $ fp 、 4096 ) ) { //データブロックを分析します if ( ! xml_parse ( $ xmlparser 、 $ xmldata 、 feof ( $ fp ) ) ) { die (印刷「エラー:」 .xml_get_error_code ( $ xmlparser ) 。 "<br> line:" 。 xml_get_current_line_number ( $ xmlparser ) 。 「<br>列:」 。 xml_get_current_column_number ( $ xmlparser ) 。 "<br>" ) ; } } xml_parser_free ( $ xmlparser ) ; ?>
上記のコードの出力は次のとおりです。
エラー: 76 ライン: 5 列: 41
XML_GET_ERROR_CODE (パーサー)
パラメーター | 説明する |
---|---|
パーサー | 必須。使用するXMLパーサーを指定します。 |