简体   繁体   中英

Confusing complete in xml_parse_into_struct

When feeding xml_parse_into_struct with the following string, the "test" is marked as complete. To me, it's not and the glitch causes trouble.

Is it being parsed correctly? Any options that can be set to prevent "test" to collapse into complete?

<?php
$s = 
'<xml>
  <test>
I feel
incomplete
  </test>
</xml>';
$p = xml_parser_create();
xml_parse_into_struct($p,$s,$vals,$index);
header('content-type:text/plain');
print_r($vals);
//output
Array
(
    [0] => Array
        (
            [tag] => XML
            [type] => open
            [level] => 1
            [value] => 

        )

    [1] => Array
        (
            [tag] => TEST
            [type] => complete
            [level] => 2
            [value] => 
I feel
incomplete

        )

    [2] => Array
        (
            [tag] => XML
            [value] => 

            [type] => cdata
            [level] => 1
        )

    [3] => Array
        (
            [tag] => XML
            [type] => close
            [level] => 1
        )

)

The behavior is correct. The tag is complete because it contains all the data and got closed and does not have any tags inside.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM