Folgende Konstanten werden von dieser Erweiterung definiert und stehen nur zur Verfügung, wenn die Erweiterung entweder statisch in PHP kompiliert oder dynamisch zur Laufzeit geladen wurde.
Hinweis:
Only available in Libxml >= 2.6.21
Hinweis:
This option is currently just available in the DOMDocument::save and DOMDocument::saveXML functions.
Hinweis:
Only available in Libxml >= 2.6.21
LIBXML_NOBLANKS option doesn't work for me and i don't understand why.
I have the following XML file:
<?xml version='1.0'?> 
<document>
    <title>Forty What?</title>
    <from>Joe</from>
    <to>Jane</to>
    <body>I know that's the answer -- but what's the question?</body>
    <blank></blank>
    <super attr='tel' attr2=' '>
        <ceva>test</ceva>
        <altceva attr="yes"/>
    </super>
</document>
I load it using:
$xml = simplexml_load_file('testxml.xml', NULL, LIBXML_NOBLANKS);
By using the parameter LIBXML_NOBLANKS i would expected to remove blank nodes such as <blank></blank> but instead when i display the array using print_r($xml) it looks like this:
<?php
SimpleXMLElement Object
(
    [title] => Forty What?
    [from] => Joe
    [to] => Jane
    [body] => I know that's the answer -- but what's the question?
    [blank] => SimpleXMLElement Object
        (
        )
    [super] => SimpleXMLElement Object
        (
            [@attributes] => Array
                (
                    [attr] => tel
                    [attr2] =>  
                ) 
            [ceva] => test
            [altceva] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                        (
                            [attr] => yes
                        )
                )
        )
)
?>
Can anyone help me ?
Appreciate.
Note: The LIBXML_NOXMLDECL constant is defined in this library but is not supported by DOMDocument (yet).
See also: http://bugs.php.net/bug.php?id=47137
<?php
print "PHP_VERSION:      ".PHP_VERSION."\n";
print "LIBXML_VERSION:   ".LIBXML_VERSION."\n";
print "LIBXML_NOXMLDECL: ".LIBXML_NOXMLDECL."\n";
$dom = new DomDocument();
$dom->loadXML("<foo />");
# This should work but doesn't.
print "DOMDocument doesn't honor LIBXML_NOXMLDECL:\n";
print $dom->saveXML(null,LIBXML_NOXMLDECL);
# This works, and will still work after the above is fixed.
print "Forwards compatible workaround:\n";
$lines = explode("\n", $dom->saveXML(null, LIBXML_NOXMLDECL), 2);
if(!preg_match('/^\<\?xml/', $lines[0]))
    print $lines[0];
print $lines[1];
?>
PHP_VERSION:      5.3.1-0.dotdeb.1
LIBXML_VERSION:   20632
LIBXML_NOXMLDECL: 2
DOMDocument doesn't honor LIBXML_NOXMLDECL:
<?xml version="1.0"?>
<foo/>
Forwards compatible workaround:
<foo/>