xsdata attrs plugin
Project description
xsdata powered by attrs!
xsData is a complete data binding library for python allowing developers to access and use XML and JSON documents as simple objects rather than using DOM.
Now powered by attrs!
Install
$ # Install with cli support
$ pip install xsdata-attrs[cli]
Generate Models
$ # Generate models
$ xsdata http://rss.cnn.com/rss/edition.rss --output attrs
Parsing document edition.rss
Analyzer input: 9 main and 0 inner classes
Analyzer output: 9 main and 0 inner classes
Generating package: init
Generating package: generated.rss
...
@attr.s
class Rss:
class Meta:
name = "rss"
version: Optional[float] = attr.ib(
default=None,
metadata={
"type": "Attribute",
}
)
channel: Optional[Channel] = attr.ib(
default=None,
metadata={
"type": "Element",
}
)
...
XML Parsing
>>> from xsdata_attrs.bindings import XmlParser
>>> from urllib.request import urlopen
>>> from generated.rss import Rss
>>>
>>> parser = XmlParser()
>>> with urlopen("http://rss.cnn.com/rss/edition.rss") as rq:
... result = parser.parse(rq, Rss)
...
>>> result.channel.item[2].title
'Vatican indicts 10 people, including a Cardinal, over an international financial scandal'
>>> result.channel.item[2].pub_date
'Sat, 03 Jul 2021 16:37:14 GMT'
>>> result.channel.item[2].link
'https://www.cnn.com/2021/07/03/europe/vatican-financial-scandal-intl/index.html'
Changelog: 23.8 (2023-08-12)
Removed python 3.6 and 3.7 support
Added official support for 3.11 and 3.12
Set xsdata minimum version v23.5
This project is still alive :)
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
xsdata_attrs-23.8.tar.gz
(18.8 kB
view hashes)
Built Distribution
Close
Hashes for xsdata_attrs-23.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4ac0e734333d0528fcf0f7e14bfb3045d9ed5fabe7aa401b9fc92a64a86653c |
|
MD5 | 2e1249b43053aed23eda617b51eb98b1 |
|
BLAKE2b-256 | f5649bf455afa1467c41efc5d85024a9a26febedc46e8dc68c3110a8bd39e854 |