Questions tagged [lxml.objectify]
48 questions
2
votes
1 answer
Python: How can I use lxml objectify's iterchildren to get details of siblings which are in a different namespace
This is my xml file.
get_subscribers_result.xml

badri
- 575
- 2
- 8
- 22
2
votes
2 answers
Add multiple of same xml subelements to existing parent element
I'm trying to take a comma seperated list [Action, Adventure, Family] and for each item in the list, create a new tag inside of a tag.
The desired output:
Action
Adventure
…

irncty
- 21
- 1
1
vote
1 answer
How to create an objectified element with text with lxml
I'd like to create an element tree (not parsing!) with lxml.objectify that might look like this:
Hello World
My first attempt was to write code like this:
import lxml.objectify as o
from lxml.etree import tounicode
r…

Andi
- 13
- 2
1
vote
1 answer
String interpolation while inserting multiple elements into xml from inside a for loop
For some reason, I found it difficult to generate an XML file by inserting multiple nodes from inside a for loop. The following does achieve that, but a couple of questions remain.
Given a list of dictionaries
dict_list = [{'x': 'abc', 'y': 'efg'},…

Jack Fleeting
- 24,385
- 6
- 23
- 45
1
vote
0 answers
How to implement methods for custom subelement in lxml?
I'm trying to implement xml composed of custom objectified elements with methods. But subelements seem to lose methods associated with them.
In particular, this works:
from lxml import etree, objectify
M =…

o1278
- 11
- 1
1
vote
2 answers
How to access xml field with lxml?
Python 3.6, Lxml, Windows 10
I am getting crazy. I want to access the item field. But I always get the error:
AttributeError: 'cython_function_or_method' object has no attribute'item'
Everything else (address fields etc...) I can access without…

Wramana
- 183
- 1
- 4
- 16
1
vote
1 answer
Parsing XML with lxml.objectify.Getting error
The following code is from 'Python for Data Analysis':
from io import StringIO
import io
tag = 'Google'
root = objectify.parse(io.StringIO(tag).getroot())
Executing the code produces the following…

RichV
- 33
- 1
- 4
1
vote
0 answers
AttributeError: no such child: - Lxml objectify
I am trying to extract coordinates from a KML file. However, I keep getting this error:
for e in doc.Document.Folder.Placemark:
File "src\lxml\objectify.pyx", line 230, in lxml.objectify.ObjectifiedElement.__getattr__
File…

Tee M
- 11
- 1
- 3
1
vote
1 answer
How do I make a class inherit from lxml.objectify.Element?
I have a Python class for a Person object which inherits xml.etree.ElementTree.Element.
from xml.etree import ElementTree
class Person(ElementTree.Element):
def __init__(self, name, age):
super().__init__("person", name=name,…

Stevoisiak
- 23,794
- 27
- 122
- 225
1
vote
0 answers
lxml function objectify.deannotate() does not remove namespaces that prepend the element name
here is the xml sample

cohortq
- 677
- 1
- 5
- 10
1
vote
1 answer
Python lxml objectify: Strange behaviour when changing an elements value
I´m new to stack overflow, so "hi" to everbody and I hope someone can help me with my question...
Recently I start to play around a bit with lxml.objectify and stumble over the following behavior, which I found to be strange.
If I just create a…

Christoph Steinbach
- 11
- 1
- 3
1
vote
1 answer
Obtain multiple slices efficiently from Objectified XML
If I have an XML which I have used lxml to Objectify, how do I get slices of the list efficiently?
My script.
# from lxml import etree
from lxml import objectify
import argparse
import os
parser =…

sayth
- 6,696
- 12
- 58
- 100
1
vote
1 answer
python: Dowloading and caching XML files - how to handle encoding declaration?
from urllib.request import urlopen
from lxml import objectify
I am trying to write a program that will download XML files into a cache and then open them using objectify. If I download the files using urlopen() then I can read them in using…

Brandon Kuczenski
- 945
- 8
- 14
1
vote
1 answer
Python LXML: Modify CDATA
When I'm manipulating XML parsed with the Python LXML module (specifically lxml.objectify, but I don't think it makes a difference), how can I preserve CDATA?
Given the following results:
>>> from lxml import objectify, etree
>>> xml = '''
…

Tom
- 7,269
- 1
- 42
- 69
1
vote
1 answer
Problems parsing XML with lxml
I've been trying to parse an XML feed into a Pandas dataframe and can't work out where I'm going wrong.
import pandas as pd
import requests
import lxml.objectify
path = "http://www2.cineworld.co.uk/syndication/listings.xml"
xml =…

elksie5000
- 7,084
- 12
- 57
- 87