Coder Social home page Coder Social logo

array2xml's Introduction

🔧 Work in progress

📌 Latest releases I've contributed to

array2xml's People

Contributors

jeckerson avatar okwinza avatar overbid avatar uldisn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

array2xml's Issues

Self-Closing does not work for Empty Elements with Attributes

I need to create elements that have attributes, but no value that are self-closing. The current code creates:

<cargo weight="19200" unit="kg">
</cargo>

but what I need is:

<cargo weight="19200" unit="kg"/>

I'm using Array2xml to create a soap message and the current result is not legal code. This would fix that issue.

Duplicate keys

I need to generate data that re-uses key names on the same level, simulating an indexed array. E.g. js2xml supports this by wrapping objects in a normal array where the duplicates are one level lower, hence not conflicting. This does not work with array2xml, so is there another way?

Example:

bla
blä

is coded like this for js2xml:

[
    {
        "tag": "bla"
    },
    {
        "tag": "bla"
    }
]

Tabs problem

Hello, i have a problem with tabs inside nodes. If node has attributes but has not any content it create empty tabs inside node, so xml is not valid.
The solution for me is to comment 336 and 375 lines ("$this->writer->text(str_repeat($this->newTab, $tabs_count));" ).
Can u comment this lines or make another solution?

Unvalid php code:

        $xmlArray = new Array2XML();
        $xmlArray->setEmptyElementSyntax(Array2xml::EMPTY_SELF_CLOSING);
        $xmlArray->setRootName("Файл");
        $xmlArray->setEncoding("WINDOWS-1251");
        $xmlArray->setVersion("1.0");
        $document = array();
        $document["а"]["a1"] = array();
        $document["а"]["a1"]["@attributes"] = array("aaa"=>"aaa");
        $xmlString = $xmlArray->convert($document);
        header('Content-type: application/xml');
        echo $xmlString;

There is a second problem for me. If node has attributes it is not auto self closed. Can u fix it too?

Improve setCDataKeys behaviour

Hi,

the method setCDataKeys needs an array as argument where the keys will be used in the code of the class.

That means it works if you use it like that:

$array2xml->setCDataKeys( array( 'content' => 'anything here which is not used' ) );

If you change this part of the code to this:

if (array_search($key, $this->CDataKeys)!==false)
{
    $this->writer->writeCData($val);
}

We would be able to use the API like this:

$array2xml->setCDataKeys( array( 'content' ) );

To not break backwards compatibility you could do both:

if (isset($this->CDataKeys[$key]) || array_search($key, $this->CDataKeys)!==false)
{
    $this->writer->writeCData($val);
}

Regards,
Daniel

setElementsAttrs function

I'm trying to utilize the setElementsAttrs and it's for the most part working as expected. However I have a variable number of Elements that need to have specific attributes that are unknown until after the array is created.

Basically what I need to do is
$array2xml->setElementsAttrs(array('group' => $group_attr, 'record' => $rec_attr[$i], 'meta' => $meta_attr[$i]));

where $i would be that specific element row.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.