Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Archive & XML file
  • Hello, Exist a class or method for manipulate them XML file ? And exist the class can to extract a archive ? Thanks
  • PHP has built-in methods for XML manipulation. You can use the Format class to convert XML to other formats, for example array or json. If your archive is a zip file, you can use the Unzip class. Other archive types are not supported.
  • Ok. In Format class, I find the method for transform an Array to XML file, but I don't find the opposite. Exist it a class or method for use the command Unix/Linux ? Method implement of exec() function ? Thanks
  • Internally to the Format class instance, everything is an array. If your input is XML, use
    $xml = Format::forge( file_get_contents( '/my/xml/file.xml', 'xml' ) );
    
  • Ok, but this method copy the xml file in an object property (only 1). Exist it a method who create an object with a property by node XML ?
  • It will not copy the xml, the xml will be parsed and stored internally in a multidimensional array. Do this so see how it is stored:
    \Debug::dump($xml->to_array());
    
  • Thanks. I test this your source code. How must to be structured the original file XML ? Because, I have this error : http://s15.postimage.org/k5evp523f/11_09_2012_15_07_05.png
  • You're XML isn't parsed, so you didn't do what I wrote:
    // create a format object from your XML
    $xml = Format::forge($myxmlstring, 'xml');
    
    // get the xml as an array
    $array = $xml->to_array();
    
    // dump the array
    Debug::dump($array);
    
  • Ok, it's good. Thanks for your help.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion