Skip to main content

Pyxml

Pure python3 alternative to stdlib xml.etree with HTML support

Install

pip install pyxml3

Advantages

  1. The default parser ignores XML Declaration Entities avoiding most if not all XML related vulnerabilities such as The Billion Laughs Attack

  2. Our XPATH implementation is much more complete than both xml.etree and even LXML. Additional functions and features are available making it easier to quickly parse complex data structures in a single line.

Examples

Standard Usage:
import pyxml

etree = pyxml.fromstring(b'<p>Hello World!</p>')
for element in etree.iter():
  print(element)

with open('example.xml', 'rb') as f:
  etree = pyxml.fromstring(f)
  print(etree)
Monkey Patch:
import pyxml
pyxml.compat.monkey_patch()

from xml.etree import ElementTree as ET

etree = ET.fromstring('<div><p class="hello world">Hello World!</p></div>')
for element in etree.iter():
  print(element)

print(etree.find('//p[starts-with(lower-case(text()), "hello")]'))
HTML:
import pyxml.html

etree = pyxml.html.fromstring('<div><p>Hello World!</p><br></div>')
for element in etree.iter():
  print(element)

print(etree.find('//p[notempty(text())]'))

Download files

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

Source Distribution

pyxml3-0.0.4.tar.gz (25.2 kB view details)

Uploaded Source

File details

Details for the file pyxml3-0.0.4.tar.gz.

File metadata

  • Download URL: pyxml3-0.0.4.tar.gz
  • Upload date:
  • Size: 25.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.3

File hashes

Hashes for pyxml3-0.0.4.tar.gz
Algorithm Hash digest
SHA256 64d58131ea578cb050bc1434925c19a6ffff4c838769aeacfe33144698633b13
MD5 1ad631ffb948a79a275716e95c7232a6
BLAKE2b-256 20bb8f0b663b03a8819fef4fdc5034c74bdc910a1c7995ef16797ed8f038d529

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.4 This release

1 file

0.0.3

1 file

0.0.2

1 file

0.0.1

1 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