Skip to main content

Allows investigation and manipulation of XML data with objects.

Project description


Makes managing XML a lot easier by making an XML document look like nested Python objects.

## Installing

Install via `pip`:

pip install xml-objects

## Usage

See [sample.xml](sample.xml) for the structure used in these examples. Taken unashamedly from Microsoft's [Sample XML](https://msdn.microsoft.com/en-us/library/ms762271.aspx). The results of the code below can be seen by running [`xml_node.py`](xml_node.py) directly.

```python
xml = XMLNode.from_file('sample.xml')
print(xml.book.price)
for book in xml.book:
print(f"{book.title.value}, {book.author.value}, {book.price.value}")
```

Which will output:

```
PS [34] master -> python .\xml_node.py

['44.95', '5.95', '5.95', '5.95', '5.95', '4.95', '4.95', '4.95', '6.95', '36.95', '36.95', '49.95']
XML Developer's Guide, Gambardella, Matthew, 44.95
Midnight Rain, Ralls, Kim, 5.95
Maeve Ascendant, Corets, Eva, 5.95
Oberon's Legacy, Corets, Eva, 5.95
The Sundered Grail, Corets, Eva, 5.95
Lover Birds, Randall, Cynthia, 4.95
Splish Splash, Thurman, Paula, 4.95
Creepy Crawlies, Knorr, Stefan, 4.95
Paradox Lost, Kress, Peter, 6.95
Microsoft .NET: The Programming Bible, O'Brien, Tim, 36.95
MSXML3: A Comprehensive Guide, O'Brien, Tim, 36.95
Visual Studio 7: A Comprehensive Guide, Galos, Mike, 49.95
```

## Future Ideas

- Script to drop into a shell with the functionality of XMLNode. Optionally, with an argument to pre-load an XML file.
- The `__str__` method should probably print out available child-nodes for ease of exploration.
- Open from URL?

## Contributing

I'd love to have people contribute. Feel free to open a pull request and we'll talk about it!

## Code of Conduct

See the [Code of Conduct](CODE_OF_CONDUCT.md).

Keywords: data xml interface update modify investigate
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: Text Processing :: Markup :: XML
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Description-Content-Type: text/markdown

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

xml-objects-0.1.3.tar.gz (3.6 kB view details)

Uploaded Source

File details

Details for the file xml-objects-0.1.3.tar.gz.

File metadata

  • Download URL: xml-objects-0.1.3.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for xml-objects-0.1.3.tar.gz
Algorithm Hash digest
SHA256 6f3e0ed696fda7867c22df4c07409346dccc632bd4281233a09ae250ffb02007
MD5 d2e5cc6a43135885e276afb0a94a019c
BLAKE2b-256 8f5dc25eea9ad246ff0cffe88bb9d927d48e687dc18e85b29c8f2f87779438b0

See more details on using hashes here.

Supported by

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