Giter Site home page Giter Site logo

lalit's People

Contributors

janise avatar mwinandy avatar rquadling avatar stickler-ci 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  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  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lalit's Issues

2 пожелания если возможно

1 insert in the the root node need to add parameters examle: creat date
2 add in line 2 format description

required result

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE yml_catalog SYSTEM "shops.dtd">
<yml_catalog date="2019-01-31 17:02">

Comments in the XML act as a sort of reset for that level.

Take the XML of ...

$xml = <<< END_XML
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<content>
    <!-- A comment -->
    <level level="1">
        <!-- A comment -->
        <level level="2">
            <!-- A comment -->
            <level level="3">
                <!-- A comment -->
                <node node="1"/>
                <node node="2"/>
                <!-- A comment -->
                <node node="3"/>
            </level>
        </level>
    </level>
</content>    
END_XML;

When processed using XML2Array::convert(), the resulting array is ...

Array
(
    [content] => Array
        (
            [level] => Array
                (
                    [level] => Array
                        (
                            [level] => Array
                                (
                                    [node] => Array
                                        (
                                            [@value] =>
                                            [@attributes] => Array
                                                (
                                                    [node] => 3
                                                )
                                        )
                                    [@attributes] => Array
                                        (
                                            [level] => 3
                                        )
                                )
                            [@attributes] => Array
                                (
                                    [level] => 2
                                )
                        )
                    [@attributes] => Array
                        (
                            [level] => 1
                        )
                )
        )
)

Licence and composer

What is the license for this package? It is possible to include it in the vendor with composer?

Some characters are modified/encoded in XML output

I'm fetching some data from a MySQL table via PDO, then using Array2XML to write that data to an XML file. The encoding of my MySQL database/table/column is utf8mb4.

My problem is that some data seems to get modified by Array2XML as it's being converted to XML.

For example, in the database I have a carriage return character which appears in the XML output as &#13;, the HTML entity encoded version of a carriage return.

Illustrative example:

<?php

// print_r($array);
[content] => "Here I have a
carriage return"

// echo $xml->saveXML();
<content>Here I have a &#13;carriage return</content>

Problem with @value elements ...

Heya,

Awesome work by both the original author & yourself 👍

Anyway, I've found what appears to be a bug. When parsing this

array (
    "hpo" => array (
        "HP_0012759" => array (
            "term" => "Neurodevelopmental abnormality",
            "@attributes" => array (
                "present" => "na"
            ),
            "onset" => array (
                "@attributes" => array (
                    "units" => "years"
                ),
                "@value" => NULL
            )
        )
    )
)

I get an exception Message: [Array2XML] Illegal character in tag name. tag: @value in node: onset

Cheers,
Algy

clean input array before using createXML() ?

Hi,
I'm converting jsons to XML using your class but I often get errors like

Uncaught Exception: [Array2XML] Illegal character in tag name. tag: $schema in node: root

Is there a way to clean the keys recursively in the array before calling createXML() so that this error is not fired ? Thanks.

CreateXML $node_name

I'd like to create XML from array and have a few questions about array2XML features.
1.
In my case XML has to star with this node:

<dpi:DPI_OECD xmlns:dpi="urn:oecd:ties:dpi:v1" xmlns:stf="urn:oecd:ties:dpistf:v1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0"
    xsi:schemaLocation="urn:oecd:ties:dpi:v1 ../XSD/DPIXML_v1.0.xsd">
    

or with SOAP signature:
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
But looks like $node_name parameter of createXML method cannot be used to create such and XML.
How to solve this?

I have a multiple nodes of same name. How to handle them in an array?

Is it possible to create partial document with Array2XML and then embed it into main XML document as some child?

xml:lang will change to 'lang' only

with xmlToArray,

if i have attributes like

<Description xml:lang="en-GB" /> Test </Description>

it gives me array like
"Description" => array:2 [ "@value" => "Test" "@attributes" => array:1 [ "lang" => "en-GB" ] ]
and the obvious ArrayToXml output:

<Description lang="en-GB" /> Test </Description>

Missing tag for 3.4.0

Can you please tag 3.4.0 - commits have been merged in but no corresponding tag exists

PHP7 specific issue in array2xml

Hello, i have found a very strange bug.

in some case the "is_numeric(key($value)" return null in php 7, but not php 5.6, ending up with an error :

[Array2XML] Illegal character in tag name. tag: 0 in node: data

The used array is (with print_r result) :

Array
(
    [element] => Array
        (
            [0] => Array
                (
                    [trigger_table] => messages
                    [action] => insert
                    [unicite] => 100001##ico-CpswP0E3EJPLAule1N5hc68TiYm_np3LMxmdk-O6LAe4P_vqcK
                    [data] => Array
                        (
                            [0] => Array
                                (
                                    [icone] => ico-CpswP0E3EJPLAule1N5hc68TiYm_np3LMxmdk-O6LAe4P_vqcK
                                    [userid] => 100001
                                    [sujet] => sujet-SOScngEPXzcQ_MBK6dMi2Fco-GbtDGewd1lRZxajkg4Jcc1jmg
                                )

                        )

                )

            [1] => Array
                (
                    [trigger_table] => messages
                    [action] => insert
                    [unicite] => 100001##ico-Y2QIAITIeorcfTONGyFfWapulT4E5B73qwCMKiEvRaAEnBOV5A
                    [data] => Array
                        (
                            [0] => Array
                                (
                                    [icone] => ico-Y2QIAITIeorcfTONGyFfWapulT4E5B73qwCMKiEvRaAEnBOV5A
                                    [userid] => 100001
                                    [sujet] => sujet-NLt1uZgkKx-7_FNqCgx7UW9myPPxKDqRJeWQTjuQ6zNtR4kA36
                                )

                        )

                )

        )

)

I can correct the error 2 way :
Bad way :

$array_good=json_decode(json_encode($array),true);

Good but i don't know why way :

          throw new Exception('[Array2XML] Illegal character in tag name. tag: '.$key.' in node: '.$node_name);
        }
        if (is_array($value) 
          && (is_null(key($value)) || is_numeric(key($value)))) {
          // MORE THAN ONE NODE OF ITS KIND;
          // if the new array is numeric index, means it is array of nodes of the same kind
          // it should follow the parent key name
          foreach ($value as $k => $v) {
            $node->appendChild(self::convert($key, $v));
          }

maybe the array i generate is wrong someway, but var_dump the before / after json result as EXACTLY the same string, so i don't know how to see the difference between the 2 array

In the php7 change http://php.net/manual/en/migration70.incompatible.php

Changes to foreach ¶

Minor changes have been made to the behaviour of the foreach control structure, primarily around the handling of the internal array pointer and modification of the array being iterated over.

foreach no longer changes the internal array pointer

Array2XML is not handling invalid characters in node values

If you do this:

print_r(\LaLit\XML2Array::createArray(\LaLit\Array2XML::createXML('myxml', ['ttt' => 'oo� o'])->saveXML()));

you'll get a PHP fatal error "Error parsing the XML string" even though the XML string is prepared by \LaLit\Array2XML itself.

The reason is that a PHP string may contain characters that are invalid in XML, see https://www.w3.org/TR/xml/#NT-Char
For example, characters x00-x09 are invalid, x02 is being used in the code example above.

Getting such characters into data is easy enough, e.g., it may happen when copying content from a PDF viewer.

Seeing how there already is exception [Array2XML] Illegal character in attribute name. possible, there should also be an exception for illegal characters in node values.

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.