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
1 answer

Adding attributes with ascending integer values to XML elements

I want to add the add attribute 'id="number"' to an existing file. But the number should be ascending in the way they are added. So right now my XML file looks like this:
JME
  • 27
  • 4
0
votes
2 answers

xml.etree.ElementTree.Element' object has no attribute 'nsmap'

I have a large number of .zip files in a folder. They are DAISY files. I need to: open each ZIP archive, open up the only XML file in the archive, extract only the numbers from the same element, for example
0
votes
3 answers
0
votes
2 answers

Splitting Large XML File into Multiple Based on Specific Node

I am attempting to split a large XML document (with 88,645 lines) into multiple XMLs based on a specific node. That specific node is . The structure of the large XML document is as follows:
moran29
  • 11
  • 1
0
votes
1 answer

How to iterate over XML children with same name as current element and avoid current element in iteration?

I have A given XML (can't change naming) that have same name for a node and its direct children, here items I want To iterate on the children only, the items that have a description field My issue The parent node of type items appears in the…
azro
  • 53,056
  • 7
  • 34
  • 70
0
votes
2 answers

Python : Sort xml file by tag content

I have this .xml example as input: 2 xyz 1 abc How can I sort the "users" by "id" number to get the following .xml as…
Billy Grant
  • 31
  • 1
  • 2
  • 6
0
votes
1 answer

Cant parse XML tree without bounds element from Pyosmium

I downloaded some data from OpenStreetMap, and have been sorting the data so i only have the nodes and ways that i need for my project (highways and the corresponding nodes in the references). To sort the XML file and create a new one, i use the…
Skovgaard
  • 11
  • 3
0
votes
0 answers

Round-trip HTML using Python xml.etree.ElementTree or lxml.ElementTree

I have code that creates and saves XML fragments. Now I would like to handle HTML as well. ElementTree.write() has a method="html" parameter that suppresses end tags for "area", "base", "basefont", "br", "col", "frame", "hr", "img", "input",…
samwyse
  • 2,760
  • 1
  • 27
  • 38
0
votes
1 answer

How to get the sibling tag value in a xml ElementTree using python,

Want to get the value of the sibling element in xml using ElementTree. sample.xml is as below want to get value 23 against John & 20 against Jin. Sam New…
MakHingse
  • 11
  • 1
0
votes
1 answer

Adding an attribute to an XML tag without affecting namespace declarations

I'm trying to add an attribute value to a tag in an XML string when the attribute is missing, and print out the modified string. Code is patchwork that I've roughly gleaned from various sources, so apologies if this isn't best practice. Here's what…
Athena
  • 155
  • 7
0
votes
2 answers

How can I extract elementary values with ElementTree in Python?

I try to extract values attributes (ex. 'Filename') of that XML file in Python. Can you help me ? Here is the MC 'Librarytest.xml' file :
Levy
  • 1
  • 1
0
votes
1 answer

retrieving xml element value by searching the element by substring in its name

I would need to retrieve xml element value by searching the element by substring in its name, eg. I would need to get value for all elements in XML file which names contains client. I found a way how to find element with xpath by an attribute, but I…
JanFi86
  • 449
  • 10
  • 29
0
votes
0 answers

python replit XML conversion not working for larger files - invalid token

I am using python on replit to convert XML files from endnote into a different XML format that can be opened in Microsoft Word's reference manager. When I tested on files with up to 6 records, it worked perfectly. When I tried on larger files with…
0
votes
1 answer

How to extract Nessus XML Data in python

So, I have some Nessus files and I would like to extract the XML data out of it. I know you can just convert to a csv within Nessus but that is not an option for me in my scenario, so I am creating a parser and converter in Python. It mostly works,…
King
  • 1
  • 1
0
votes
2 answers

XML parsing with class will not find the values

I will split a large XML to small branches and than parse only this parts. I search modified timestamp "mod_time" tag which is avaliable in "contacts" tag, but my object function call, doesn't find the value. In some contacts is also some tags…
Paul-ET
  • 68
  • 1
  • 6
1 2 3
99
100