Skip to main content

A Python interface to xmlsq.

Project description

The utility xmlsq performs simple and full XPath 1.0 queries on an XML document.

>>> import xmlsq
>>> xml = r"<a><b foo='baz'>hello</b><b>world</b><e /></a>"
>>> xmlsq.get_text(xml, "//b")
'hello'
>>> xmlsq.get_text(xml, "//b[2]")
'world'
>>> xmlsq.full_query(xml, "//b")
'<b foo="baz">hello</b>\n<b>world</b>\n'
>>> xmlsq.get_text(xml, "//b/@foo")
'baz'
>>> xmlsq.full_query(xml, "//b/@foo")
'foo="baz"\n'
>>> xmlsq.full_query(xml, "/a", xmlsq.Opts.RAW)
'<a><b foo="baz">hello</b><b>world</b><e/></a>'
>>> xmlsq.count(xml, "//b")
2
>>> xmlsq.count(xml, "//notthere")
0
>>> xmlsq.count(xml, "//e")
1
>>> xmlsq.full_query(xml, "2+3.5")
'5.500000'

xmlsq.get_text() extracts the text value of the first node found selected by the query.

xmlsq.full_query() outputs the result of the full XPath 1.0 query as a string.

xmlsq.count() computes the integer value of count(query).

For xmlsq.get_text() and xmlsq.count() the query must evaluate to a node.

For full details of all available methods and options, please see the documentation.

System requirements

Windows platforms with Python 3. Requires the Windows library diXmlsq.dll to be installed on your system, available from https://www.cryptosys.net/xmlsq/.

Acknowledgment

This software is based on the pugixml library (https://pugixml.org). Pugixml is Copyright (C) 2006-2019 Arseny Kapoulkine.

Contact

For more information or to make suggestions, please contact us at https://cryptosys.net/contact/

David Ireland
DI Management Services Pty Ltd
Australia
4 June 2020

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

xmlsq-0.9.0a0.zip (8.6 kB view details)

Uploaded Source

File details

Details for the file xmlsq-0.9.0a0.zip.

File metadata

  • Download URL: xmlsq-0.9.0a0.zip
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.9.1 pkginfo/1.4.1 requests/2.18.3 setuptools/36.2.7 requests-toolbelt/0.8.0 tqdm/4.15.0 CPython/2.7.12

File hashes

Hashes for xmlsq-0.9.0a0.zip
Algorithm Hash digest
SHA256 da8491a4564e42fd402fe60c74d47f40e0be270f50b52ec6259147deba9d6ac2
MD5 66289798176ff3343dab5f533afbe786
BLAKE2b-256 00398de8a9122a4d4db48594ba0f593d056b4d77f428cff2ed7f38463460d75c

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