|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-06-16 14:17 UTC] sander@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 10 00:00:01 2025 UTC |
If there is a mismatched tag in XML and the parsing fails, when calling xml_get_current_line_number or xml_get_current_column_number, the results are not consistent between runs. Here's a code sample and results. I've noticed that if I initialize $done to FALSE, it doesn't happen, but I don't know how that could be related. I also tried shortening the XML sample, but then it doesn't happen either. I've seen XML errors in the past that would cause Apache to seg fault when calling the functions to get details about the XML error and this may be the same problem. <?php $xml = "<ABCDEFGH>\n<ABCDEFGHIJKLM>1234567890</ABCDEFGHIJKLM>\n<ABCDEFGH>"; // Note last closing tag should be "</ABCDEFGH>" while(!$done) { for($i = 0; $i < 2; $i++) { $xmlParser = xml_parser_create(); xml_parse($xmlParser, $xml, TRUE); $pass[$i]["Line"] = xml_get_current_line_number($xmlParser); $pass[$i]["Column"] = xml_get_current_column_number($xmlParser); xml_parser_free($xmlParser); } if($pass[0]["Line"] != $pass[1]["Line"] || $pass[0]["Column"] != $pass[1]["Column"]) { echo "Pass1: Line " . $pass[0]["Line"] . ", Column " . $pass[0]["Column"] . "<br>"; echo "Pass2: Line " . $pass[1]["Line"] . ", Column " . $pass[1]["Column"]; $done = TRUE; } } ?> Typical results: Pass1: Line 3, Column 10 Pass2: Line 2, Column 52 Pass1: Line 1, Column 63 Pass2: Line 3, Column 10