From 1f3bd8265a166c1dc77a880d9fd3b1540a1ac6ae Mon Sep 17 00:00:00 2001 From: Davide Brunato Date: Wed, 28 Aug 2019 11:18:03 +0200 Subject: [PATCH] Update README.rst --- README.rst | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/README.rst b/README.rst index e3259c0..853d123 100644 --- a/README.rst +++ b/README.rst @@ -21,11 +21,11 @@ You can install the package with *pip* in a Python 2.7 or Python 3.4+ environmen For using it import the package and apply the selectors on ElementTree nodes: - >>> import elementpath - >>> from xml.etree import ElementTree - >>> root = ElementTree.XML('') - >>> elementpath.select(root, '/A/B2/*') - [, , ] +>>> import elementpath +>>> from xml.etree import ElementTree +>>> root = ElementTree.XML('') +>>> elementpath.select(root, '/A/B2/*') +[, , ] The *select* API provides the standard XPath result format that is a list or an elementary datatype's value. If you want only to iterate over results you can use the generator function @@ -34,26 +34,25 @@ datatype's value. If you want only to iterate over results you can use the gener The selectors API works also using XML data trees based on the `lxml.etree `_ library: - >>> import elementpath - >>> import lxml.etree as etree - >>> root = etree.XML('') - >>> elementpath.select(root, '/A/B2/*') - [, , ] - +>>> import elementpath +>>> import lxml.etree as etree +>>> root = etree.XML('') +>>> elementpath.select(root, '/A/B2/*') +[, , ] When you need to apply the same XPath expression to several XML data you can also use the *Selector* class, creating an instance and then using it to apply the path on distinct XML data: - >>> import elementpath - >>> import lxml.etree as etree - >>> selector = elementpath.Selector('/A/*/*') - >>> root = etree.XML('') - >>> selector.select(root) - [, , ] - >>> root = etree.XML('') - >>> selector.select(root) - [, , , ] +>>> import elementpath +>>> import lxml.etree as etree +>>> selector = elementpath.Selector('/A/*/*') +>>> root = etree.XML('') +>>> selector.select(root) +[, , ] +>>> root = etree.XML('') +>>> selector.select(root) +[, , , ] Public API classes and functions are described into the `elementpath manual on the "Read the Docs" site `_.