elementtree Questions

6

Solved

I'd like to preserve comments as faithfully as possible while manipulating XML. I managed to preserve comments, but the contents are getting XML-escaped. #!/usr/bin/env python # add_host_to_tomca...
Milksop asked 6/11, 2015 at 19:0

3

Solved

Good day everybody. I'm trying to read, parse and use an xml-file using ElementTree. Following data: <level> <leveldata> <level name="hh" difficulty="Easy" lenght="3600"> &lt...
Davin asked 11/4, 2014 at 1:2

7

Solved

I retrieve an XML documents this way: import xml.etree.ElementTree as ET root = ET.parse(urllib2.urlopen(url)) for child in root.findall("item"): a1 = child[0].text # ok a2 = child[1].text # ok...
Munificent asked 20/9, 2014 at 16:1

5

Solved

I have an xml doc that I am trying to parse using Etree.lxml <Envelope xmlns="http://www.example.com/zzz/yyy"> <Header> <Version>1</Version> </Header> <Body&gt...
Lippold asked 23/11, 2010 at 10:54

2

Solved

I'm trying to parse an xml document that has a number of undefined entities that cause a ParseError when I try to run my code, which is as follows: import xml.etree.ElementTree as ET tree = ET.pa...
Sandi asked 21/12, 2017 at 4:5

3

Solved

Trying to parse XML, with ElementTree, that contains undefined entity (i.e.  ) raises: ParseError: undefined entity   In Python 2.x XML entity dict can be updated by creating parser (doc...
Awfully asked 7/2, 2013 at 6:23

1

Using python import lxml I am able to print a list of the path for every element recursively: from lxml import etree root = etree.parse(xml_file) for e in root.iter(): path = root.getelementpath(e...
Mercy asked 1/7, 2021 at 18:35

5

Solved

I have: import xml.etree.ElementTree as ET def strip_tag_name(t): t = elem.tag idx = k = t.rfind("}") if idx != -1: t = t[idx + 1:] return t events = ("start", "end") title = None for ev...
Gers asked 4/7, 2019 at 12:49

3

Solved

I'm trying to parse below XML using Python ElementTree to product output as below. I'm trying to write modules for top elements to print them. However It is slightly tricky as category element may ...
Criollo asked 28/1, 2015 at 14:27

9

This XML file is named example.xml: <?xml version="1.0"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http...
Facilitate asked 1/3, 2012 at 9:21

12

Solved

I've written a fairly simple filter in python using ElementTree to munge the contexts of some xml files. And it works, more or less. But it reorders the attributes of various tags, and I'd like i...
Undistinguished asked 29/4, 2010 at 23:48

2

Solved

I read the following: "Deprecated since version 3.2, will be removed in version 3.9: Use list(elem) or iteration." (https://docs.python.org/3.8/library/xml.etree.elementtree.html#xml.etre...
Waal asked 6/4, 2021 at 23:36

4

Solved

I'm using Python and BeautifulSoup to parse and access elements from an XML document. I modify the values of a couple of the elements and then write the XML back into the file. The trouble is that ...
Austenite asked 11/10, 2019 at 16:2

2

Solved

I have an XML file in the following format <?xml version="1.0" encoding="utf-8"?> <foo> <bar> <bat>1</bat> </bar> <a> <b xmlns="urn:schemas-micros...
Meanwhile asked 29/7, 2016 at 16:9

2

Solved

I have an input XML file: <?xml version='1.0' encoding='utf-8'?> <configuration> <runtime name="test" version="1.2" xmlns:ns0="urn:schemas-microsoft-com:asm.v1"> <ns0:assemb...
Naphthol asked 23/2, 2016 at 10:24

3

Solved

I send a GET request to the CareerBuilder API : import requests url = "http://api.careerbuilder.com/v1/jobsearch" payload = {'DeveloperKey': 'MY_DEVLOPER_KEY', 'JobTitle': 'Biologist'} r = reque...
Gerita asked 25/3, 2013 at 18:24

11

Solved

I am generating an XML document in Python using an ElementTree, but the tostring function doesn't include an XML declaration when converting to plaintext. from xml.etree.ElementTree import Element...
Lure asked 12/3, 2013 at 8:42

10

Solved

I have an object that can build itself from an XML string, and write itself out to an XML string. I'd like to write a unit test to test round tripping through XML, but I'm having trouble comparing ...
Myrticemyrtie asked 26/11, 2008 at 19:9

3

Solved

I am trying to merge multiple XML files together using Python and no external libraries. The XML files have nested elements. Sample File 1: <root> <element1>textA</element1> &...
Passover asked 14/2, 2013 at 15:51

3

Solved

Can someone please help convert the following XML file to Pandas dataframe: <?xml version="1.0" encoding="UTF-8" ?> <root> <bathrooms type="dict"> <n35237 type...
Tartar asked 24/10, 2018 at 12:21

7

Solved

That is, all text and subtags, without the tag of an element itself? Having <p>blah <b>bleh</b> blih</p> I want blah <b>bleh</b> blih element.text return...
Shipshape asked 19/12, 2008 at 10:33

3

Solved

Is there a way to define the default/unprefixed namespace in python ElementTree? This doesn't seem to work... ns = {"":"http://maven.apache.org/POM/4.0.0"} pom = xml.etree.ElementTree.parse("pom.x...
Adelbert asked 30/11, 2015 at 23:33

2

Solved

I want to read a XML string, edit it and save it as a XML file. However I get the mentioned error in the title when I do .write() I found out that when you read an XML string using ElementTree.from...
Oliana asked 20/6, 2019 at 8:59

3

Solved

I am using ElementTree to build an XML file. When I try to set an element's attribute with ET.SubElement().__setattr__(), I get the error AttributeError: __setattr__. import xml.etree.cElementTre...
Manrope asked 13/9, 2013 at 22:39

2

Solved

I'm trying to create a function which counts words in pptx document. The problem is that I can't figure out how to find only this kind of tags: <a:t>Some Text</a:t> When I try to: pr...
Aquileia asked 23/11, 2016 at 19:0

© 2022 - 2024 — McMap. All rights reserved.