Search code examples
phpxmlsimplexml

i cant type the xml in php


this is my xml file..

<?xml version="1.0" encoding="ISO-8859-1"?>
    <OTA_Langee xmlns="http://www.opentravel.org/OTA/2003/05" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opentravel.org/OTA/2003/05 OTA_VehResRS.xsd" Version="2.001"><information><Descriptions>bla bla bla
    <Dis1>bla bla bla</Dis1>
    </Descriptions></information></OTA_Langee>

and this is my php file

    <?php 

 $xml = simplexml_load_file('deneme.xml');

echo $xml->information;

?>

but nothin display when i run .. i want write between data.. but it does not type anything.. any help please?


Solution

  • That's because information still has a descriptions. This is the output for print_r($xml):

    SimpleXMLElement Object
    (
        [@attributes] => Array
            (
                [Version] => 2.001
            )
    
        [information] => SimpleXMLElement Object
            (
                [Descriptions] => bla bla bla
    
    
            )
    
    )
    

    So you'd access it like this:

    echo $xml->information->Descriptions;
    

    Output:

    bla bla bla


    Instead of echo, if you use print_r on $xml->information, you'll get this:

    SimpleXMLElement Object
    (
        [Descriptions] => bla bla bla
    
    
    )