Skip to content

XML Reader #104

Open
Open

Description

@applibs

Can you prepare XML Reader please?

Activity

  1. abcarroll commented on Dec 28, 2019

    @abcarroll

    I had assumed it was not implemented due to the fact it is so trivial. Simply use simplexml_load_file(), for example, and cast it to an array and use the ArrayReader.

  2. applibs commented on Dec 29, 2019

    @applibs
    Author

    If its soo simple should you complete your library with xml reader please?

  3. Baachi commented on Apr 16, 2020

    @Baachi
    Contributor

    @applibs Don't be harsh to everyone. @abcarroll Is right, XML can contain a really generic data structure with attributes and elements, so there is no way we can provide an easy to use the reader for that.

    If your XML is quite simple and you don't need to access attributes, you can do this:

    $xml = simplexml_load_file('/path/to/foo.xml');
    $data = json_decode(json_encode($xml), true);
    $reader = new ArrayReader($data);

    If you need a more advanced approach, you need to this your own. You can use the DOM PHP extension or the XmlReader from the PHP core.

    https://www.php.net/manual/en/dom.examples.php
    https://www.php.net/manual/en/class.xmlreader.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions