Giter Site home page Giter Site logo

tours-xml-parser's Introduction

XML Parser

In the following task, you are given an XML text representing a set of tours, and you have to convert it into the text in a required format.

Write a function xmlToCSV($text) that parses an input text in XML format (presented below) and converts it to the text in delimited format (also presented below).

  • Input XML text contains the elements representing a set of tours.
  • Output text represents compressed and simpler form of XML.

Output comments:

  • "Title" is a string, with HTML entities (like '&') converted back to symbols
  • "Code" is a string
  • "Duration" is an integer
  • "Inclusions" is a string (just simple text: without HTML tags, double or triple spaces; with HTML entities converted back to symbols)
  • "MinPrice" is a float with 2 digits after the decimal point; it's the minimal EUR value among all tour departures, taking into account the discount, if presented (for example, if the price is 1724 and the discount is "15%", then the departure price evaluates to 1465.40).

Output format:

Title|Code|Duration|Inclusions|MinPrice|
Tour title|AE-19|18|The tour price cover all services|2121.20

Installation

Download or clone repository:

$ git clone https://github.com/vukanac/tours-xml-parser.git

Install required libraries:

$ composer install

Example of use

Project have a sample file with a tours data/tours.xml. In the process, the complex data structure will be converted to a simpler, pipe (|) separated fields in file data/tours.csv.

$ php index.php

For PHP memory limit of 128MB, it is possible to convert 20.000 tours in XML structure.

$ php test_20k.php

tours-xml-parser's People

Contributors

vukanac avatar

Watchers

 avatar  avatar

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.