Ankündigung

Einklappen
Keine Ankündigung bisher.

[Erledigt] XML Parsingfehler von simplexml_load_string und Zend_Config_Xml?

Einklappen

Neue Werbung 2019

Einklappen
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • [Erledigt] XML Parsingfehler von simplexml_load_string und Zend_Config_Xml?

    Hallo zusammen,

    woran könnte es liegen, dass folgende Probleme auftreten:

    Bei simplexml_load_string:
    => Die Struktur wird richtig erfasst, jedoch der Text nicht.
    Bei Zend_Config_Xml:
    => Es wird nur ein Element von <ad> erfasst, aber diesmal ist der Text drin.

    XML:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <test>
        <ad>
            <id>1</id>
            <b_id>8</b_id>
            <link>http://www.example.com/?B_ID=48</link>
            <k_foto>http://www.example.com/48.jpg</k_foto>
            <b><![CDATA[hier steht ein Text]]></b>
        </ad>
        <ad>
            <id>1</id>
            <b_id>8</b_id>
            <link>http://www.example.com/?B_ID=48</link>
            <k_foto>http://www.example.com/48.jpg</k_foto>
            <b><![CDATA[hier steht ein Text]]></b>
        </ad>
        <ad>
            <id>1</id>
            <b_id>8</b_id>
            <link>http://www.example.com/?B_ID=48</link>
            <k_foto>http://www.example.com/48.jpg</k_foto>
            <b><![CDATA[hier steht ein Text]]></b>
        </ad>
    </test>
    Ausgabe simplexml_load_string:
    Code:
    SimpleXMLElement Object
    (
        [ad] => Array
            (
                [0] => SimpleXMLElement Object
                    (
                        [id] => 1
                        [b_id] => 8
                        [link] => http://www.example.com/?B_ID=48
                        [k_foto] => http://www.example.com/48.jpg
                        [b] => SimpleXMLElement Object
                            (
                            )
    
                    )
    
                [1] => SimpleXMLElement Object
                    (
                        [id] => 1
                        [b_id] => 8
                        [link] => http://www.example.com/?B_ID=48
                        [k_foto] => http://www.example.com/48.jpg
                        [b] => SimpleXMLElement Object
                            (
                            )
    
                    )
    
                [2] => SimpleXMLElement Object
                    (
                        [id] => 1
                        [b_id] => 8
                        [link] => http://www.example.com/?B_ID=48
                        [k_foto] => http://www.example.com/48.jpg
                        [b] => SimpleXMLElement Object
                            (
                            )
    
                    )
    
            )
    
    )
    Ausgabe Zend_Config_Xml:
    Code:
    Zend_Config_Xml Object
    (
        [_skipExtends:protected] => 
        [_allowModifications:protected] => 
        [_index:protected] => 0
        [_count:protected] => 1
        [_data:protected] => Array
            (
                [ad] => Zend_Config Object
                    (
                        [_allowModifications:protected] => 
                        [_index:protected] => 0
                        [_count:protected] => 5
                        [_data:protected] => Array
                            (
                                [id] => 1
                                [b_id] => 8
                                [link] => http://www.example.com/?B_ID=48
                                [k_foto] => http://www.example.com/48.jpg
                                [b] => hier steht ein Text
                            )
    
                        [_skipNextIteration:protected] => 
                        [_loadedSection:protected] => 
                        [_extends:protected] => Array
                            (
                            )
    
                        [_loadFileErrorStr:protected] => 
                    )
    
            )
    
        [_skipNextIteration:protected] => 
        [_loadedSection:protected] => 
        [_extends:protected] => Array
            (
            )
    
        [_loadFileErrorStr:protected] => 
    )
    Vielen Dank

  • #2
    Schwache Problembeschreibung. Versuch es bitte noch mal. Ansonsten kann ich dir nur raten, es mit Debugging zu versuchen.

    Gruß
    [URL]http://hallophp.de[/URL]

    Kommentar


    • #3
      Hallo Asipak,

      in der XML steht doch "hier steht ein Text". Dieser Text fehlt in der Ausgabe von simplexml_load_string.

      Bei Zend_Config_Xml wird nur eines der 3 <ad> Blöcke ausgegeben.

      Ich konnte mittlerweile herausfinden, dass es mit simplexml_load_string funktioniert, wenn ich die CDATA Blöcke entferne. Doch die Anwendung dieser in der XML ist richtig und auch sinnvoll.

      Ist das ein PHP Fehler in der Funktion simplexml_load_string?

      EDIT:
      Hab eine Lösung

      So geht es auch mit CDATA:

      PHP-Code:
      $xml simplexml_load_string($xmlnullLIBXML_NOCDATA); 

      Kommentar

      Lädt...
      X