Questions tagged [elementtree]

ElementTree is a Python library for creating and parsing XML.

ElementTree is a Python library for creating and parsing XML.

from xml.etree import ElementTree

An alternative implementation on top of libxml and libxslt, with an expanded API is lxml, see the tag.

2858 questions
0
votes
0 answers

Is this a bug in Google Colab or am I doing something wrong?

This says input is an object of ET but isn't input a function? Besides, I never made an object named input so why is this happening? What should I do to resolve this? Code: import xml.etree.ElementTree as ET import…
0
votes
1 answer

How to get the value of below mentioned xml in Python using ElementTree?

I'm using ElemetTree to iterate all the xml tag. Whereas some of my xml contents look like below xml. When iterating the xml getting the tag text as None not "This is the Result of Chrome Browser"
0
votes
0 answers

exception': "Failed to parse QName 'SOAP:', line 1, column 7

I got this xml in response from api but after then I want to fetch values of xml attributes using xpath but in the first step tree = etree.parse(StringIO(hotel_details_logs)) i'm getting exception/error. "
0
votes
2 answers

Failing at inserting a new line in existing xml file

I am currently writing a python code to manage an existing xml file. I have this existing xml structure in a model file : 2 english Z
0
votes
1 answer

Use xml.etree.elementtree to process xml with xmlns="http://www.w3.org/2005/Atom"

I'm trying to process the data extracted from the web. The decoded raw data was bytes of xml file. I had some old code that just magically worked. However, I'm not sure what they were doing since it's been a while. import urllib, urllib.request url…
0
votes
1 answer

Turn nested python dictionary into xml

I have df that I turn into a python dictionary, then convert it to an xml format. Column A Column B getTitle status getTitle timestamp submitBook title submitBook date submitBook numPages I used: `book_df = df.groupby(['Column…
Lilly
  • 1
0
votes
2 answers

Python extracts texts following a span tag inside another span tag

Is there a way to extract "Part-time, Full-time" and "On Campus" from the span tag? Master / Part-time, Full-time
bilbao
  • 13
  • 4
0
votes
2 answers

Python xml.etree.ElementTree add subelement without console output

I want to add a Subelement to a XML file without writing the content to the console. I am doing the following to add a subelement to a XML file: import xml.etree.ElementTree as…
VKlue
  • 21
  • 4
0
votes
0 answers

logic gates in xml file and python (fault tree analysis )

I want to make fault tree analysis of system using python and xml file, but I couldn't find enough material to help me in that. Let say I have a simple xml file which has Top event and OR logic gate which connects three events A1,A2,A3. I want…
Daly
  • 1
0
votes
0 answers

Create dataFrame from parent and child

I'm working with data exported from Apple Health as an xml file. workouts = [node for node in nodes if node.tag == 'Workout'] ET.dump(workouts[0]) Shows me there is a child element, WorkoutStatistics.
0
votes
1 answer

How to find duplicates in multiple XML files and merge into one XML file in python?

I have 3 XML files in which I need to compare against each other. I need to find the duplicates in each file by a part ID inside of these app tags. Then, the file that is the largest (i.e. has the most data) I need to merge those duplicates to that…
0
votes
0 answers

How does the author know the element exists?

In Patrick Loeber's How to Analyze Apple Health Data with Python (https://www.python-engineer.com/posts/apple-health-data-python/), he suggests iterating over 'Workouts' here: workout_list = [x.attrib for x in root.iter('Workout')]. How does he know…
0
votes
2 answers

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

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: Lore 9 12.34 Ipsum
JME
  • 27
  • 4
0
votes
1 answer

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

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: Lore 9 12.34
JME
  • 27
  • 4
0
votes
1 answer

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

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:
JME
  • 27
  • 4
1 2 3
99
100