Amol Hatwar wrote:
Hi,

The PHP Manual entry for xml_parser_set_option lists an option called:
XML_OPTION_SKIP_WHITE. I really couldn't decipher what this option
enables or disables.

The manual entry itself is a bit terse:
"Whether to skip values consisting of whitespace characters."

Doodling around with it in code got me no luck. Any ideas on what kind
of whitespaces it does supress?

Look at this script:

<?php
$simple = "<root>\n\t</root>";

$p = xml_parser_create();

xml_parser_set_option($p, XML_OPTION_SKIP_WHITE, $argv[1]);
xml_parse_into_struct($p, $simple, $vals);

xml_parser_free($p);
echo "\nVals array\n";
print_r($vals);
?>

// sets XML_OPTION_SKIP_WHITE to false
[EMAIL PROTECTED] ~/tmp $ php simple.php 0
Array
(
    [0] => Array
        (
            [tag] => ROOT
            [type] => complete
            [level] => 1
            [value] =>

        )

)

// sets XML_OPTION_SKIP_WHITE to 1
[EMAIL PROTECTED] ~/tmp $ php simple.php 1
Array
(
    [0] => Array
        (
            [tag] => ROOT
            [type] => complete
            [level] => 1
        )

)

With XML_OPTION_SKIP_WHITE = 1 sets are whitespace chars discarded from the result. In first output is index 'value' which contains only "\n\t" - whitespace chars. Second output is without this index in array - whitespace chars are ignored.

If you have node which contains text and whitespace chars "<node> some text</node>" then whitespace chars are not discarded. Only content of nodes with whitespace chars only are discarded (<node> </node> -> <node></node>).


--
Ondrej Ivanic
([EMAIL PROTECTED])

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to