Skip to content

Magenaut

  • Home
  • Topics
    • Notes
    • Tutorial
    • Bug fixing
    • Extension
    • Server
  • Q&A
  • Privacy Policy
  • About

xml

What is the fastest way to parse large XML docs in Python?

August 17, 2022 by Magenaut

I am currently running the following code based on Chapter 12.5 of the Python Cookbook:

Categories Python, Q&A Tags parsing, performance, python, xml Leave a comment

Can ElementTree be told to preserve the order of attributes?

August 17, 2022 by Magenaut

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.

Categories Python, Q&A Tags elementtree, python, xml Leave a comment

How can this function be rewritten to implement OrderedDict?

August 17, 2022 by Magenaut

I have the following function which does a crude job of parsing an XML file into a dictionary. Unfortunately, since Python dictionaries are not ordered, I am unable to cycle through the nodes as I would like. How do I change this so it outputs an ordered dictionary which reflects the original order of the … Read more

Categories Python, Q&A Tags collections, lxml, python, xml Leave a comment

Remove namespace and prefix from xml in python using lxml

August 16, 2022 by Magenaut

I have an xml file I need to open and make some changes to, one of those changes is to remove the namespace and prefix and then save to another file.
Here is the xml:

Categories Python, Q&A Tags lxml, namespaces, python, xml Leave a comment

How to output CDATA using ElementTree

August 16, 2022 by Magenaut

I’ve discovered that cElementTree is about 30 times faster than xml.dom.minidom and I’m rewriting my XML encoding/decoding code. However, I need to output XML that contains CDATA sections and there doesn’t seem to be a way to do that with ElementTree.

Categories Python, Q&A Tags python, xml Leave a comment

using lxml and iterparse() to parse a big (+- 1Gb) XML file

August 16, 2022 by Magenaut

I have to parse a 1Gb XML file with a structure such as below and extract the text within the tags “Author” and “Content”:

Categories Python, Q&A Tags iterparse, lxml, parsing, python, xml Leave a comment

How do I use a default namespace in an lxml xpath query?

August 15, 2022 by Magenaut

I have an xml document in the following format:

Categories Python, Q&A Tags lxml, python, xml, xpath Leave a comment

How to use Python XML findall to find ”

August 14, 2022 by Magenaut

I’m trying to do a find all from a Word document for <v:imagedata r:id="rId7" o:title="1-REN"/> with namespace xmlns:v="urn:schemas-microsoft-com:vml" and I cannot figure out what on earth the syntax is.

Categories Python, Q&A Tags python, urn, vml, xml Leave a comment

How can I create a Word document using Python?

August 13, 2022 by Magenaut

I’d like to create a Word document using Python, however, I want to re-use as much of my existing document-creation code as possible. I am currently using an XSLT to generate an HTML file that I programatically convert to a PDF file. However, my client is now requesting that the same document be made available … Read more

Categories Python, Q&A Tags ms-word, python, xml, xslt Leave a comment

Empty list returned from ElementTree findall

August 13, 2022 by Magenaut

I’m new to xml parsing and Python so bear with me. I’m using lxml to parse a wiki dump, but I just want for each page, its title and text.

Categories Python, Q&A Tags elementtree, parsing, python, wikimedia-dumps, xml Leave a comment
Older posts
Newer posts
← Previous Page1 … Page6 Page7 Page8 Page9 Next →
  1. michealSmith07 on Is there a way to dynamically refresh the less command?August 21, 2022

    That is a very nice post. I like this post.

  2. anonymous on Fix libwacom9 dependency issue when upgrade DebianJune 27, 2022

    saved my day!! Thanks for the help…

  3. sreedhar on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    Thanks its working

  4. saintnick on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    remove libwacom2 worked for me as well

  5. ranafoul on Fix libwacom9 dependency issue when upgrade DebianApril 22, 2022

    apt remove libwacom2 helped on kali 2022.01. gr8

.net ajax asp.net asp.net-core asp.net-mvc asp.net-mvc-3 asp.net-mvc-4 asp.net-web-api bash c# command-line css custom-post-types custom-taxonomy dataframe dictionary django entity-framework functions gridview html iis javascript jquery json linux list matplotlib numpy pandas php plugin-development plugins posts python python-2.7 python-3.x security shell shell-script sql string vb.net webforms wp-query

© 2026 Magenaut • Built with GeneratePress