Visualizzazione dei risultati da 1 a 2 su 2

Discussione: domanda su DOM

  1. #1

    domanda su DOM

    Ciao a tutti, volevo sapere se per attivare il DOM, dovevo modificare il file php.ini, perche' facendo un esempio da un libro mi da sempre errore. Uso wamp con PHP5, e MYSQL5
    l'errore e questo:
    codice:
    Warning: DOMDocument::loadXML() [function.DOMDocument-loadXML]: Premature end of data in tag Shoes line 9 in Entity, line: 9 in C:\wamp\www\libro\capitolo23\simple_dom_1.php on line 17
    
    Warning: DOMDocument::loadXML() [function.DOMDocument-loadXML]: Premature end of data in tag Shoes line 3 in Entity, line: 9 in C:\wamp\www\libro\capitolo23\simple_dom_1.php on line 17
    Unable to load in XML Text
    il pezzo di codice dove mi da l'errore e' questo:
    codice:
    <?php
    
    $xmldoc = <<<XMLDOC
    <?xml version="1.0" encoding="utf-8"?>
    
    <sh:Shoes xmlns:sh='http://localhost/shoestore'>
    <sh:Shoe>
    <sh:BrandName>Nike</sh:BrandName>
    <sh:Model>Super Runner 150</sh:Model>
    <sh:Price>109.99</sh:Price>
    </sh:Shoe>
    <sh:Shoes>
    XMLDOC;
    
    $dom = new DOMDocument();
    $dom->preserveWhiteSpace = FALSE;
    $result = $dom->loadXML($xmldoc);
    if ($result == FALSE)
    die ('Unable to load in XML Text');
    
    $rootNode = $dom->documentElement;
    
    echo $rootNode->nodeName . "
    \n";
    echo $rootNode->localName . "
    \n";
    echo $rootNode->prefix . "
    \n";
    echo $rootNode->namespaceURI . "
    \n";
    //ecc ecc

  2. #2
    Leggendo l'errore che PHP restituisce, ovvero
    Premature end of data in tag Shoes
    Puoi accorgerti che il tag <sh:Shoes> non viene chiuso, ma viene erroneamente riaperto alla fine dell'XML.

    prova a cambiarlo.

    codice:
    <?xml version="1.0" encoding="utf-8"?>
    
    <sh:Shoes xmlns:sh='http://localhost/shoestore'>
    <sh:Shoe>
    <sh:BrandName>Nike</sh:BrandName>
    <sh:Model>Super Runner 150</sh:Model>
    <sh:Price>109.99</sh:Price>
    </sh:Shoe>
    </sh:Shoes>
    Michele Castellucci
    Sviluppatore Web del Consorzio CottonBit
    Consorzio Cottonbit
    Risorse per la programmazione
    Dire Fare Programmare!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.