Skip to main content

KXMLParser

Rest-Framework Parser Convert xml to json, including attributes

##Getting Started

Dependencies

You need Python 3.7 or later

You also need json and xmltodict packages available from PyPI, if you have pip just run:

pip install xmltodict

####Instalation

pip install KXMLParser

Setting parser, edit settings.py :

REST_FRAMEWORK = {
    'DEFAULT_PARSER_CLASSES': [
        'KXMLParser.parsers.XMLParser',
        
    ],
}

Example

<?xml version="1.0" encoding="UTF-8"?>
<pessoas>
    <pessoa codigo="1" nome="Fulano" telefone="2222-2222">
        <endereco referencia='Ponto de Onibus, Pomar'>
            <rua>Rua Marfim</rua>
            <numero>1</numero>
            <cidade>Ouro Preto</cidade>
            <cep>35400-000</cep>
        </endereco>
    </pessoa>
    <pessoa codigo="2" nome="Beltrano" telefone="3333-3333">
            <endereco referencia='Ponto de Onibus, Pomar'>
            <rua>Rua Marfim</rua>
            <numero>2</numero>
            <cidade>Ouro Preto</cidade>
            <cep>35400-000</cep>
        </endereco>
    </pessoa>
    <pessoa codigo="1" nome="Ciclano" telefone="4444-4444">
            <endereco referencia='Ponto de Onibus, Pomar'>
            <rua>Rua Marfim</rua>
            <numero>3</numero>
            <cidade>Ouro Preto</cidade>
            <cep>35400-000</cep>
        </endereco>
    </pessoa>
</pessoas>

Result

{
    "pessoas": {
        "pessoa": [
            {
                "@codigo": "1",
                "@nome": "Fulano",
                "@telefone": "2222-2222",
                "endereco": {
                    "@referencia": "Ponto de Onibus, Pomar",
                    "rua": "Rua Marfim",
                    "numero": "1",
                    "cidade": "Ouro Preto",
                    "cep": "35400-000"
                }
            },
            {
                "@codigo": "2",
                "@nome": "Beltrano",
                "@telefone": "3333-3333",
                "endereco": {
                    "@referencia": "Ponto de Onibus, Pomar",
                    "rua": "Rua Marfim",
                    "numero": "2",
                    "cidade": "Ouro Preto",
                    "cep": "35400-000"
                }
            },
            {
                "@codigo": "1",
                "@nome": "Ciclano",
                "@telefone": "4444-4444",
                "endereco": {
                    "@referencia": "Ponto de Onibus, Pomar",
                    "rua": "Rua Marfim",
                    "numero": "3",
                    "cidade": "Ouro Preto",
                    "cep": "35400-000"
                }
            }
        ]
    }
}

Features

  • File structure for PyPI packages
  • Setup with package informations
  • License example

Release files for KXMLParser 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for KXMLParser 0.0.5
File Size Uploaded
KXMLParser-0.0.5.tar.gz 2.4 kB Details

Release files / KXMLParser-0.0.5.tar.gz

Download URL KXMLParser-0.0.5.tar.gz
Size 2.4 kB
Tags Source
SHA-256 checksum
How to use checksums
20629b7680c62f151ce52a53837b8b3cdc6b6f1825ffe88487109883371d5474
BLAKE2b-256 checksum
How to use checksums
606fc11ad49cee9de7f1897f107d3ad26c93fcdbc3afa69d9a015fe3ab4be848
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.8.2 requests/2.27.1 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.64.0 CPython/2.7.18

Release history Release notifications | RSS feed

This release

0.0.5 This release

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page