Questions tagged [celementtree]

The cElementTree module is a C implementation of the Python ElementTree API, optimized for fast parsing and low memory use. The module is deprecated since Python 3.3.

The cElementTree module is a C implementation of the Python ElementTree API, optimized for fast parsing and low memory use.

Since Python 3.3, the module is deprecated and there is no need to explicitly import it. Just use xml.etree.ElementTree (see https://docs.python.org/3/whatsnew/3.3.html#xml-etree-elementtree).

77 questions
0
votes
0 answers

Python xml tree structure

How can I follow a way to print data in doc tag in each loop? My code root = ET.Element("root") doc = ET.SubElement(root, "doc") tree = ET.ElementTree(root) for row in tree.iter(): ET.SubElement(doc, "sku", name="sku").text = siradakiSku …
0
votes
1 answer

Can't import cElementTree on Python 2.7

I cannot import xml.etree.cElementTree on Python 2.7. On the web, it says its already implemented, so I don't have to install it. (It's working on Python 3.6 for me, but I need 2.7 for reasons here) Thats the console output: Python 2.7.15+ (default,…
Standard
  • 1,450
  • 17
  • 35
0
votes
2 answers

How can I remove XML parts with iterparse with parents included using ElementTree in Python?

I have multiple large files that I need to import and iterate through them - all of them are xmls and have the same tree structure. The structure is something like this with some extra text apart from the ID so under the Start there are more…
Anna Semjén
  • 787
  • 5
  • 14
0
votes
1 answer

URL in all XML Element Tags

I am using the cElementTree package in Python and am having trouble with the element's tags. They include an attribute in the tag itself. It seems to be a problem with the parser. Please review the code below: from xml.etree import cElementTree…
Tanner Clark
  • 631
  • 1
  • 8
  • 19
0
votes
1 answer

Python: Access nested sub elements in xml file

I have an xml file structered as follow: A Pralognan suivre
marOne
  • 129
  • 2
  • 13
0
votes
1 answer

Extract elements from an XML file and write to another using cElementTree module

I have a large XML file and I want to extract some tags and write them in another xml file. I wrote this code: import xml.etree.cElementTree as CE tree = CE.ElementTree() root = CE.Element("root") i = 0 for event, elem in CE.iterparse('data.xml'): …
Oussama He
  • 555
  • 1
  • 10
  • 31
0
votes
2 answers

cElementTree with python not working as expected

I wrote a python script to read xml files generated from a software. I used xml.etree.cElementTree to parse the xml. It had been working properly, but suddenly today I find the script is not working. I do not think there was any change in the…
Debopam Parua
  • 460
  • 1
  • 4
  • 24
0
votes
1 answer

Take 2 XML elements and merge into 1 new element - Python

I am currently working on a project using OpenStreetMap XML documents. Part of the project is to verify some of the data and it's consistency. I am fairly new with Python and with working with XML files so I have really no idea where to start. Here…
Sam L
  • 162
  • 1
  • 8
0
votes
1 answer

cElementTree to extract data from XML python

I have an XML file whose structure is similar to the following:
Sparker0i
  • 1,787
  • 4
  • 35
  • 60
0
votes
2 answers

python element tree extract value not working

I'm trying to extract the values in with ElementTree and i'm getting the following error. Can anyone help show me what I'm doing wrong? from pastebin import PastebinAPI from xml.etree import cElementTree as ET import time x =…
dobbs
  • 1,089
  • 6
  • 22
  • 45
0
votes
1 answer

Segmentation fault (core dumped) with cElementTree on ubuntu

I am parsing xml files on a linux ubuntu machine using a python script and the cElementTree package. After a while (at the same point every time) it results in the error Segmentation fault (core dumped) This seems to be a C error and hence I think…
carl
  • 4,216
  • 9
  • 55
  • 103
0
votes
1 answer

Using cElementTree to parse attributes

I am learning cElementTree and my XML looks like this.... I am trying to obtain the "updated" text ( which I can! ) and the attribute value of "href" in the "link" node ( which I can't ).
Jane Wilkie
  • 1,703
  • 3
  • 25
  • 49
0
votes
1 answer

ElementTree Replace Tag Attribute and Update File

I am trying to clean an XML file by replacing tag attributes with the correct value. When I run my code below, the tag attribute is updated but only in the Element Tree tag object, the XML file is not being updated/saved. Is there a way to…
JT3
  • 1
  • 1
  • 5
0
votes
0 answers

How to extract attribute values from xml?

If I have the following xml: I can locate all concept1 branches by doing import xml.etree.cElementTree as ET tree =…
brucezepplin
  • 9,202
  • 26
  • 76
  • 129
0
votes
1 answer

how to use ElementTree to take out particular xml data from xml

I am getting an xml response like below false 1c7fd51c-8f12-46e8-a4b7-f1f9c614df82 PARENT
Ruchir Bharadwaj
  • 1,132
  • 4
  • 15
  • 31