elementtree Questions

4

Solved

I have a huge xml file (1 Gig). I want to move some of the elements (entrys) to another file with the same header and specifications. Let's say the original file contains this entry with tag <t...
Bogey asked 9/8, 2011 at 23:20

3

I'm parsing XML in python by ElementTree import xml.etree.ElementTree as ET tree = ET.parse('try.xml') root = tree.getroot() I wish to parse all the 'xml' files in a given directory. The user s...
Nathanialnathaniel asked 28/3, 2013 at 10:30

4

How can one access NS attributes through using ElementTree? With the following: <data xmlns="http://www.foo.net/a" xmlns:a="http://www.foo.net/a" book="1" category="ABS" date="2009-12-22">...
Gutsy asked 23/12, 2009 at 16:19

2

Solved

I'm parsing an XML file via Element Tree in python and and writing the content to a cpp file. The content of children tags will be variant for different tags. For example first event tag has party ...
Blare asked 22/3, 2013 at 10:30

4

Solved

I want to replace child elements from one tree to another , based on some criteria. I can do this using Comprehension ? But how do we replace element in ElementTree?
Hanghangar asked 13/1, 2012 at 3:15

8

Solved

I have the following XML which I want to parse using Python's ElementTree: <rdf:RDF xml:base="http://dbpedia.org/ontology/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#...
Odontoblast asked 13/2, 2013 at 12:8

2

I am trying to build an ElementTree from a string. When I do the following (as set out in Python ElementTree: Parsing a string and getting ElementTree instance), I get an Element instead of an Elem...
Garrett asked 27/11, 2015 at 17:52

9

Solved

I have an XML document in which I want to search for some elements and if they match some criteria I would like to delete them However, I cannot seem to be able to access the parent of the element...
Maximinamaximize asked 27/7, 2011 at 15:45

4

Solved

I write a program using just like below from xml.etree.ElementTree import ET xmlroot = ET.fromstring([my xml content]) for element in xmlroot.iterfind(".//mytag"): do some thing it works fine...
Rustproof asked 25/6, 2015 at 7:34

3

ElementTree.parse() fails in the simple example below with the error xml.etree.ElementTree.ParseError: XML or text declaration not at start of entity: line 2, column 0 The XML looks valid and ...
Linctus asked 15/3, 2016 at 19:44

13

I want to use the method of findall to locate some elements of the source xml file in the ElementTree module. However, the source xml file (test.xml) has namespaces. I truncate part of xml file as ...
Garrett asked 16/11, 2012 at 7:53

12

Solved

I am using the builtin Python ElementTree module. It is straightforward to access children, but what about parent or sibling nodes? - can this be done efficiently without traversing the entire tree...
Simplehearted asked 31/1, 2010 at 5:2

3

Solved

I'm Actually New to Python and BS4. And I Decided to create a script that will scrape a website, oscarmini.com to be precise, the code was running fine untill today when I wanted to modify it, I ke...
Patagium asked 10/7, 2018 at 3:44

5

Solved

I have XML data that looks like: <xml> The captial of <place pid="1">South Africa</place> is <place>Pretoria</place>. </xml> I would like to be able to extrac...
Orson asked 13/11, 2011 at 12:36

1

I can't find a practical solution in the documentation of ElementTree module for avoiding getting "TypeError: cannot serialize None (type NoneType)" when I try to set an attribute to None. Like her...
Scrogan asked 2/6, 2020 at 16:23

4

How do I set the text field of of ElementTree Element from its constructor? Or, in the code below, why is the second print of root.text None? import xml.etree.ElementTree as ET root = ET.fromstri...
Cratch asked 7/8, 2013 at 2:53

5

Solved

I'm trying to develop simple Python (3.2) code to read XML files, do some corrections and store them back. However, during the storage step ElementTree adds this namespace nomenclature. For example...
Johnsten asked 24/1, 2012 at 6:53

2

Solved

I'm using xml.etree.ElementTree to parse xml file. I'm parsing xml file in the following way: import xml.etree.ElementTree as ET tree = ET.parse(options.xmlfile) root = tree.getroot() This is my...
Gown asked 11/8, 2016 at 21:3

3

Solved

I got a debugging question. Since I am quite new here, please forgive possible janky walls-of-text. After many hours I finally got elementtree to do what I want, but I cannot output my results, b...
Curare asked 15/9, 2014 at 1:59

3

I am learning ElementTree in python. Everything seems fine except when I try to parse the xml file with prefix: test.xml: <?xml version="1.0"?> <abc:data> <abc:country name="Liech...
Outside asked 14/11, 2012 at 3:30

6

Solved

Whenever I call ElementTree.tostring(e), I get the following error message: AttributeError: 'Element' object has no attribute 'getroot' Is there any other way to convert an ElementTree object in...
Temple asked 8/3, 2013 at 22:13

12

Solved

I'm looking for an XML to dictionary parser using ElementTree, I already found some but they are excluding the attributes, and in my case I have a lot of attributes.
Sangfroid asked 7/10, 2011 at 7:38

15

Solved

I receive xml strings from an external source that can contains unsanitized user contributed content. The following xml string gave a ParseError in cElementTree: >>> print repr(s) '<C...
Newhall asked 24/10, 2012 at 9:18

8

Solved

Background I am using SQLite to access a database and retrieve the desired information. I'm using ElementTree in Python version 2.6 to create an XML file with that information. Code import sqlit...
Ebberta asked 2/3, 2015 at 15:48

6

Solved

For: <foo> <bar key="value">text</bar> </foo> How do I get "value"? xml.findtext("./bar[@key]") Throws an error.
Crock asked 1/1, 2011 at 5:16

© 2022 - 2024 — McMap. All rights reserved.