Skip to main content

An simple and easy method to find and replace values of xml

Project description

lgpdXml

1 - pip Install

pip install lgpdXml

2 - example find value of tag

#library
from lgpdXml import find, replace

#text
xml = '''<CNPJ>012.345.678/0001-01</CNPJ>
<NOMERAZAO>CLAUDIO TORRES ARBE</NOMERAZAO>
<CNPJ>001.001.001/0001-01</CNPJ>'''

#find using tag
nome = find(xml,'<NOMERAZAO>','</NOMERAZAO>')

#result
print(nome)

#all results of tag
cnpj = find(xml,'<CNPJ>','</CNPJ>')

#results
print(cnpj)

#specifying the index
cnpj = find(xml,'<CNPJ>','</CNPJ>')[1]

#result
print(cnpj)

#looking for tag that doesn't exist
email = find(xml,'<EMAIL>','</EMAIL>')

#result
print(email)

3 - example replace value

#library
from lgpdXml import find, replace

#text
xml = '''<CNPJ>012.345.678/0001-01</CNPJ>
<NOMERAZAO>CLAUDIO TORRES ARBE</NOMERAZAO>
<CNPJ>001.001.001/0001-01</CNPJ>'''

#find using tag
nome = find(xml,'<NOMERAZAO>','</NOMERAZAO>')[0]

#all results of tag
cnpj = find(xml,'<CNPJ>','</CNPJ>')[1]

#replace tag
xml = replace(xml,'****','<NOMERAZAO>',nome,'</NOMERAZAO>')

#replace tag
xml = replace(xml,'****','<CNPJ>',cnpj,'</CNPJ>')

#result
print(xml)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lgpdXml-0.0.3.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

lgpdXml-0.0.3-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

Details for the file lgpdXml-0.0.3.tar.gz.

File metadata

  • Download URL: lgpdXml-0.0.3.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.0

File hashes

Hashes for lgpdXml-0.0.3.tar.gz
Algorithm Hash digest
SHA256 b8bfab0e6566b8782c89ec81686bc756f09a006ad8c2d3a7307477a5433f36ec
MD5 1c66cc516c472bfa09d1619deca3e6f4
BLAKE2b-256 9761e20d28271f4aa03eac3c0eee45bff6d967e3f749592799f2a17e9cead47e

See more details on using hashes here.

File details

Details for the file lgpdXml-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: lgpdXml-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 2.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.0

File hashes

Hashes for lgpdXml-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 12fd3807853a5f6847e9e5f2ca15df4eeeef88c5e6ca1db048e2c4fd83bc6836
MD5 d4b5592decb767a5c98ce24448c4f10f
BLAKE2b-256 ae1a26eb8f6db7a0fcf829abe3b9ee5ae25608f3ac3f8a82a1b5d5809ac319c9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page