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")
>>> xmlsq.get_text(xml, "//b[2]")
>>> xmlsq.full_query(xml, "//b")
'<b foo="baz">hello</b>\n<b>world</b>\n'
>>> xmlsq.get_text(xml, "//b/@foo")
>>> xmlsq.full_query(xml, "//b/@foo")
>>> xmlsq.full_query(xml, "/a", xmlsq.Opts.RAW)
'<a><b foo="baz">hello</b><b>world</b><e/></a>'
>>> xmlsq.count(xml, "//b")
>>> xmlsq.count(xml, "//notthere")
>>> xmlsq.count(xml, "//e")
>>> xmlsq.full_query(xml, "2+3.5")

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


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


For more information or to make suggestions, please contact us at

David Ireland
DI Management Services Pty Ltd
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.

Files for xmlsq, version 0.9.0a0
Filename, size File type Python version Upload date Hashes
Filename, size (8.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page