PHP Doku:: Vordefinierte Konstanten - libxml.constants.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzXML-ManipulationlibxmlVordefinierte Konstanten

Ein Service von Reinhard Neidl - Webprogrammierung.

libxml

<<Ressource-Typen

The libXMLError class>>

Vordefinierte Konstanten

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.

LIBXML_COMPACT (integer)
Activate small nodes allocation optimization. This may speed up your application without needing to change the code.

Hinweis:

Only available in Libxml >= 2.6.21

LIBXML_DTDATTR (integer)
Default DTD attributes
LIBXML_DTDLOAD (integer)
Load the external subset
LIBXML_DTDVALID (integer)
Validate with the DTD
LIBXML_NOBLANKS (integer)
Remove blank nodes
LIBXML_NOCDATA (integer)
Merge CDATA as text nodes
LIBXML_NOEMPTYTAG (integer)
Expand empty tags (e.g. <br/> to <br></br>)

Hinweis:

This option is currently just available in the DOMDocument::save and DOMDocument::saveXML functions.

LIBXML_NOENT (integer)
Substitute entities
LIBXML_NOERROR (integer)
Suppress error reports
LIBXML_NONET (integer)
Disable network access when loading documents
LIBXML_NOWARNING (integer)
Suppress warning reports
LIBXML_NOXMLDECL (integer)
Drop the XML declaration when saving a document

Hinweis:

Only available in Libxml >= 2.6.21

LIBXML_NSCLEAN (integer)
Remove redundant namespaces declarations
LIBXML_PARSEHUGE (integer)
Sets XML_PARSE_HUGE flag, which relaxes any hardcoded limit from the parser.
LIBXML_XINCLUDE (integer)
Implement XInclude substitution
LIBXML_ERR_ERROR (integer)
A recoverable error
LIBXML_ERR_FATAL (integer)
A fatal error
LIBXML_ERR_NONE (integer)
No errors
LIBXML_ERR_WARNING (integer)
A simple warning
LIBXML_VERSION (integer)
libxml version like 20605 or 20617
LIBXML_DOTTED_VERSION (string)
libxml version like 2.6.5 or 2.6.17

2 BenutzerBeiträge:
- Beiträge aktualisieren...
silver dot alecs at yahoo dot com
6.04.2010 11:22
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.
zachatwork at gmail dot com
10.02.2010 8:30
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/>



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)