elementtree

Failing at inserting a new line in existing xml file

Failing at inserting a new line in existing xml file Question: I am currently writing a python code to manage an existing xml file. I have this existing xml structure in a model file : <MYPROJECT> <VERSION>2</VERSION> <LANGUAGE>english</LANGUAGE> <FILE> <FILENAME>Z</FILENAME> </FILE> <PANEL1> <SOURCE> <LAYER>MISSING</LAYER> <NAME>MISSING</NAME> <ID>MISSING</ID> </SOURCE> </PANEL1> </MYPROJECT> I need to be able to …

Total answers: 2

How to add an XML element to an existing text in a XML file with python

How to add an XML element to an existing text in a XML file with python Question: I have a problem with some values not being declared as XML elements in my XML files. But for further processing, I need them to be an element. Example: <A> <B id="254"> <C>Lore</C> <D>9</D> 12.34 </B> <B id="255"> …

Total answers: 1

Adding attributes with ascending integer values to XML elements only if they have children

Adding attributes with ascending integer values to XML elements only if they have children Question: I want to add the add attribute ‘id="number"’ to an existing file. id attributes should only be added if the element has at least one child. So right now my XML file looks like this: <Invoice> <Fussteil> <Summen> <QF/> <UstSatz>21.00</UstSatz> …

Total answers: 1

Adding attributes with ascending integer values to XML elements

Adding attributes with ascending integer values to XML elements Question: I want to add the add attribute ‘id="number"’ to an existing file. But the number should be ascending in the way they are added. So right now my XML file looks like this: <Invoice> <Fussteil> <Summen> <QF/> <UstSatz>21.00</UstSatz> <Betrag> <Bezeichnung>Steuerbetrag</Bezeichnung> <QF>124</QF> <Wert>8.8</Wert> </Betrag> <Betrag> <Bezeichnung>steuerpflichtiger …

Total answers: 1

Cant parse XML tree without bounds element from Pyosmium

Cant parse XML tree without bounds element from Pyosmium Question: I downloaded some data from OpenStreetMap, and have been sorting the data so i only have the nodes and ways that i need for my project (highways and the corresponding nodes in the references). To sort the XML file and create a new one, i …

Total answers: 1

Get items from xml Python

Get items from xml Python Question: I have an xml in python, need to obtain the elements of the "Items" tag in an iterable list. I need get a iterable list from this XML, for example like it: Item 1: Bicycle, value $250, iva_tax: 50.30 Item 2: Skateboard, value $120, iva_tax: 25.0 <?xml version="1.0" encoding="UTF-8" …

Total answers: 1

retrieving xml element value by searching the element by substring in its name

retrieving xml element value by searching the element by substring in its name Question: I would need to retrieve xml element value by searching the element by substring in its name, eg. I would need to get value for all elements in XML file which names contains client. I found a way how to find …

Total answers: 1

Get values from an xml file with python

Get values from an xml file with python Question: Context: I want to obtain information from an xml file. when doing print "<Element ‘vocation’ at 0x000001C9C7849040>" I do not want that message to appear but the value Original file XML: <?xml version="1.0"?> <spells> <instant name="spell 1"> <vocation name="men 50"/> <vocation name="men 100"/> </instant> <instant name="spells …

Total answers: 1

XPath get one attribute or another?

XPath get one attribute or another? Question: I have a Python XML XPath expression ancestor-or-self::*[@foo]/@foo, and I need to modify it to get attribute @foo if it exists otherwise get attribute @bar. I’ve tried to use or operator similar to condition like [@foo or @bar], but got an expression error. Asked By: Defect1ve || Source …

Total answers: 1