![Xmltojson](https://cdn2.cdnme.se/5447227/9-3/16_64e61dfc9606ee7f98e9879e.png)
![xmltojson xmltojson](https://cdnimage.xyz/Images/hhtqvietsub.com/xmltojson.png)
Return json.dumps(self.toDict(), indent=indent) Return elements that match the given xpath. Use this to set or reset the contents of the XmlDocument. :param: filename Set this argument if you want to parse from a file. :param: xml Set this argument if you want to parse from a string. Initialize later XmlDocument will be initialized with "".
![xmltojson xmltojson](https://i.stack.imgur.com/CRx1N.png)
You can do it later with the 'set' method. You don't have to initialize the XmlDocument during instantiation There are two ways to initialize the XmlDocument contents: cleaner access to some common lxml.etree functionsĭef _init_(self, xml = '', filename=None):
![xmltojson xmltojson](https://www.testwo.com/attachments/12697/1550741417486.png)
:param: element a normal etree.Element instance I use the following class in my projects. You could use xmltodict but you will have to pay the penalty of parsing the XML again. When I do anything with XML in python I almost always use the lxml package.
![Xmltojson](https://cdn2.cdnme.se/5447227/9-3/16_64e61dfc9606ee7f98e9879e.png)