xml-parsing

Iteratively parse a large XML file without using the DOM approach

霸气de小男生 提交于 2019-12-04 11:50:45
I have an xml file <temp> <email id="1" Body="abc"/> <email id="2" Body="fre"/> . . <email id="998349883487454359203" Body="hi"/> </temp> I want to read the xml file for each email tag. That is, at a time I want to read email id=1..extract body from it, the read email id=2...and extract body from it...and so on I tried to do this using DOM model for XML parsing, since my file size is 100 GB..the approach does not work. I then tried using: from xml.etree import ElementTree as ET tree=ET.parse('myfile.xml') root=ET.parse('myfile.xml').getroot() for i in root.findall('email/'): print i.get('Body'

How to convert jenkins job configuration config.xml to YAML format in python to be used jenkins-job-builder?

雨燕双飞 提交于 2019-12-04 09:57:59
jenkins-job-builder is a nice tool to help me to maintain jobs in YAML files. see example in configuration chapter. Now I had lots of old jenkins jobs, it will be nice to have a python script xml2yaml to convert the existing jenkins job config.xml to YAML file format. Do you any suggestions to had a quick solution in python ? I don't need it to be used in jenkins-job-builder directly, just can be converted it into YAML for reference. For the convert, some part can be ignored like namespace. config.xml segment looks like: <project> <logRotator class="hudson.tasks.LogRotator"> <daysToKeep>-1<

python xml.etree.ElementTree append to subelement

我的未来我决定 提交于 2019-12-04 09:30:48
问题 I am trying to use xml.etree.ElementTree to parse a xml file, find a specific tag, append a child to that tag, append another child to the newly created tag and add text to the latter child. My XML: <root> <a> <b> <c>text1</c> </b> <b> <c>text2</c> </b> </a> </root> Desired XML: <root> <a> <b> <c>text1</c> </b> <b> <c>text2</c> </b> <b> <c>text3</c> </b> </a> </root> Current code: import xml.etree.ElementTree as ET tree = ET.parse('test.xml') root = tree.getroot() for x in root.iter(): if (x

How Can I Speed Up Android XML Parsing?

廉价感情. 提交于 2019-12-04 08:52:02
Good afternoon (depending on where you live)! I'm fairly new to Android development and I'm currently working on moving the functionality from an existing iOS app to Android. Part of this functionality is to parse a "large" (~13,000 line) RSS XML file that contains about 500 entries. I've spent anywhere from 10-15 hours researching XML parsing on Android AND trying out the major XML parsers: DOM, SAX, and Pull-parsing. Here are my results, running within' the emulator on my box (32-bit Windows Vista, 2.2 GHz Dual CPU, 3 GB RAM): SAX: ~6:00 minutes Pull-Parsing: ~4:00 minutes DOM: Greater than

Validating a large XML file ~400MB in PHP

ぐ巨炮叔叔 提交于 2019-12-04 08:18:57
I have a large XML file (around 400MB) that I need to ensure is well-formed before I start processing it. First thing I tried was something similar to below, which is great as I can find out if XML is not well formed and which parts of XML are 'bad' $doc = simplexml_load_string($xmlstr); if (!$doc) { $errors = libxml_get_errors(); foreach ($errors as $error) { echo display_xml_error($error); } libxml_clear_errors(); } Also tried... $doc->load( $tempFileName, LIBXML_DTDLOAD|LIBXML_DTDVALID ) I tested this with a file of about 60MB, but anything a lot larger (~400MB) causes something which is

Workaround for XMLSchema not supporting maxOccurs larger than 5000

青春壹個敷衍的年華 提交于 2019-12-04 07:31:52
My problem is with parsing an XSD Schema that has elements with maxOccurs larger than 5000 (but not unbounded ). This is actually a know issue in either Xerces (which I'm using, version 2.9.1) or JAXP, as described here: http://bugs.sun.com/view_bug.do;jsessionid=85335466c2c1fc52f0245d20b2e?bug_id=4990915 I already know that if I changed the maxOccurs numbers in my XSD from numbers larger than 5000 to unbounded all works well. Sadly, this is not an option in my case (I cannot meddle with the XSD file). My question is: Does someone know some other workaround in Xerces for this issue? Or Can

Clojure Leining REPL OutOfMemoryError Java heap space

孤人 提交于 2019-12-04 07:18:49
I am trying to parse a fairly small (< 100MB) xml file with: (require '[clojure.data.xml :as xml] '[clojure.java.io :as io]) (xml/parse (io/reader "data/small-sample.xml")) and I am getting an error: OutOfMemoryError Java heap space clojure.lang.Numbers.byte_array (Numbers.java:1216) clojure.tools.nrepl.bencode/read-bytes (bencode.clj:101) clojure.tools.nrepl.bencode/read-netstring* (bencode.clj:153) clojure.tools.nrepl.bencode/read-token (bencode.clj:244) clojure.tools.nrepl.bencode/read-bencode (bencode.clj:254) clojure.tools.nrepl.bencode/token-seq/fn--3178 (bencode.clj:295) clojure.core

Converting a Cognos XML Schema file to XML using Javascript code

↘锁芯ラ 提交于 2019-12-04 06:53:08
问题 I found many "converters" online that will do this for you, but I haven't been able to find any source code that I can easily implement. I was wondering if anyone would be so kind to provide me with suggestions or even provide me with code that will do this task for me. I am trying to convert to XML so it will be easier to parse. I am trying to convert this (Cognos XML Schema)... <?xml version="1.0" encoding="utf-8" ?> - <dataset xmlns="http://developer.cognos.com/schemas/xmldata/1/" xmlns:xs

root of the xml file is giving as NONE why?

荒凉一梦 提交于 2019-12-04 06:47:38
问题 from elementtree import ElementTree as ET tree= ET.parse(r'N:\myinternwork\files xml of bus systems\testonieeebus.xml','r') root= tree.getroot() print(root) now the error is in output as it is giving none <?xml version="1.0" encoding="UTF-8"?> <bookstore> <book category="cooking"> <author>Giada De Laurentiis</author> </book> </bookstore> 回答1: The following code is enough. You don't need to open the file at beginning. ET.parse will do it for you if you provide the correct path. In your code

Can't build app when I import Xerces library (exit value 1)

给你一囗甜甜゛ 提交于 2019-12-04 05:40:16
I cannot seem to get my app to build when I import in the Xerces library. I am already using the multidex due to previous issues and therefore I know this is all setup properly. I have spend a couple of days now looking online and trying all sorts of versions of Xerces and tweaks to my build.gradle but cannot work out the issue. I have tried cleaning re-building, re-setting Android Studio/my PC, using a jar directly compiling and now officially out of ideas. Below is my build.gradle setup: android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultConfig { applicationId "#packageid#"