Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
XML Attributes?
  • Hello all,

    I am currently working on an application that generates XML from a properly formed multi-dimensional array. 

    Passing in the array to the forge class works fine. 

    Format::forge($array)->to_xml()

    However, there are some fields that are required to have certain attributes.

    For ex:

    <asset type="full">

    Is there any way to accomplish this using the forge, or any other class, assuming that I include an attribute index for each item in the array?
  • HarroHarro
    Accepted Answer
    to_xml() has no support for attributes.

    If you have complex XML structures, it's virtually impossible to represent them as an array. You may have to write your own generator. Check PHP's simplexml extension.
  • Thanks. I know that SimpleXML has an addAttribute class that I can utilize. Just wanted to see if there was an easier way around!
  • I know.

    It is very difficult to represent and node info, and attributes, in a standard array structure, without it becoming the same complicated mess as XML itself.

Howdy, Stranger!

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

In this Discussion