Tagged Questions
2
votes
1answer
43 views
Python XML parsing example
I need to simplify data in an XML to be able to read it as a single table, thus a csv. I found some Python 2.7 examples with ElementTree, but so far I could not tailor it to work further down the ...
0
votes
1answer
36 views
using “getElementsByTagName” to get tag <string name=“ID”> in python
my XML file is
<list>
<ProfileDefinition>
<string name="ID">nCGhwaZNpy6</string>
<string name="name">02.11.2013 Scott Mobile</string>
<decimal ...
1
vote
1answer
45 views
How to verify xml encoding
I am trying to parse an XML file that was created internally at my company. The file is supposed to be UTF-16 encoded but I am getting an error with the Python script that I am writing (see below). ...
0
votes
2answers
25 views
lxml raises a TypeError on using a simple custom parser
I have written the following simple parser (to showcase the problem in my slightly more complicated program) which extracts the titles from all of the entries in the DBLP xml database.
from lxml ...
0
votes
2answers
48 views
How to parse an xml data which is stored in a variable?
<myroot> <data txt="some0" txt1 = "some1" txt2 = "some2" >
<data2>
< bank = "SBI" bank2 = "SBI2" >
<data2>
...
0
votes
1answer
30 views
Error while parsing xml file in python
This is the xml file I am trying to parse. This file does not have a root tag.
<data txt="some0" txt1 = "some1" txt2 = "some2" >
<data2>
< bank = "SBI" bank2 = "SBI2" ...
2
votes
2answers
98 views
xml.etree.ElementTree get node depth
The XML:
<?xml version="1.0"?>
<pages>
<page>
<url>http://example.com/Labs</url>
<title>Labs</title>
<subpages>
...
0
votes
1answer
66 views
Getting a memory error when parsing a large XML file in Python
My XML file looks like this:
<root>
<group from="1", to="100">
<link target="1"/>
...
<link target="100"/>
</group>
...
</root>
I have a 6000 ...
0
votes
1answer
18 views
How to obtain the “nodeValue” by python?
I am trying to parse some XML file like following:
<foo
...
</M1>
<foo2 CHAR="A" NUM="8" TYPE="beta">
<SEQ>
12345
</SEQ>
<REGION ...
0
votes
1answer
33 views
How to getElementsByClassName by using python xml.dom.minidom?
I want to obtain the body of all elements that do have a specific class.
Python xml.dom.minidom has a method for getting an element by id, getElementById() but I need to get all elements that do ...
1
vote
0answers
56 views
Fastest method for SAX parsing in Python
I have an XML document (1.5MB) that needs to be parsed in real-time for a web service that I am developing. I am using the cElementTree Python library which, according to this post, is the preferred ...
0
votes
2answers
54 views
How to parse and extract a specific element from a HTML document in Python?
There are lots of XML and HTML parsers in Python and I am looking for a simple way to extract a section of a HTML document, preferably using an XPATH construct but that's only optional.
Here is an ...
0
votes
2answers
37 views
Parsing output of svn list command - Cannot get attribute
I am using the saved output of :
svn list -R --xml directory
As input to a python script, my current code using python 2.6.5:
import os
import os.path
import sys
import lxml.etree
if ...
1
vote
3answers
58 views
How do I parse some of the data from a large xml file?
I need to extract the location and radius data from a large xml file that is formatted as below and store the data in 2-dimensional ndarray. This is my first time using Python and I can't find ...
0
votes
2answers
45 views
using numerical filters to define what print list is used (I assume if filters)
I have some code which parses an xml file obtained from a url, using the following code:
pattern4 = re.compile('title=\'Naps posted: (.*) Winners:')
pattern5 = re.compile('Winners: (.*)\'><img ...
0
votes
0answers
56 views
How to make lxml's tostring print XML with encoded special characters?
I have the following XML:
<x>Boys' Footbal</x>
I parse it with python's lxml, then print with tostring, and the & apos; is printed as '.
Question: How can I get the ...
0
votes
1answer
67 views
Unable to parse XML file with python.Want to remove a line from python file for it .Help me to remove the line
hello I am using etree for the parsing the xml file.I am having a problem parsing a xml file.Below are details.
<niktoscan .................................... >#don't want to remove this line
...
0
votes
1answer
44 views
Python - print pretty XML create opening and closing tags for empty tags text
I'm writing a python application that creates an ElementTree (XML) and then writing it to a file, using minidom's toprettyxml();
final_tree = minidom.parseString(ET.tostring(root))
...
1
vote
1answer
92 views
Reading Maven Pom xml in Python
I have a pom file that has the following defined:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
...
0
votes
2answers
35 views
XML Error: Not well formed
I got this error that says not well formed and it has to do with xml itself. How do i tell python to ignore a section of the xml file?
<?xml version="1.0"?>
<solution version="0.1" ...
1
vote
0answers
48 views
Parsing very large xml file (18.5 GB) in python using iterparse in lxml with limited RAM. Is there a way? [duplicate]
I am trying to parse a large XML data dump (18.5 GB) with limited RAM (~6 GB). We only want to grab a few tags from each object and make a hashtable with those tags. We are currently using iterparse ...
1
vote
0answers
43 views
From XML to template file- attributes starting with @
I'm stuck with sending xml to template engine in gae.
I'm using a suggested xmltodict here http://stackoverflow.com/a/10199714/27186
The problem is at attribute level:
...
0
votes
0answers
9 views
DMOZ RDF dump to MySQL or SQLite [duplicate]
I have downloaded the latest rdf dump from dmoz.org
now i want to create either SQLite or MySQL database (preferably MySQL) in python. python by default doesn't support MySQL, you'll have to install ...
1
vote
1answer
60 views
parse data from a website (.xml)
I trying to parse data from a website, and i can do the following:
import xml.etree.ElementTree as ET
from urllib import urlopen
link = ...
0
votes
2answers
26 views
Duplicate values in list when parsing xml?
I have xml:
<?xml version="1.0" encoding="UTF-8"?>
<rows>
<row>
<ro new="TEMP_1">TEMP_11</ro>
<ro new="TEMP_2">TEMP_12</ro>
<ro ...
0
votes
2answers
51 views
How to pass xml as a parameter in python script?
I have the parameters to be passed to my python code saved in an xml file.
How to pass this xml as a parameter to my python code?
Can someone please help on this?
Thanks in Adavce!
0
votes
3answers
191 views
Parsing large xml data using python's elementtree
I'm currently learning how to parse xml data using elementtree. I got an error that say:ParseError: not well-formed (invalid token): line 1, column 2.
My code is right below, and a bit of the xml ...
0
votes
1answer
36 views
Method 'hasattr' not testing property correctly?
I'm really stuck with this! I'm getting some product data from Amazon, which is returned as an XML. When the search keyword is valid, it returns the XML with nodes Items > Item. With a wrong keyword, ...
1
vote
1answer
18 views
XML Library Suggestions
I don't know if this is the right place to ask this question, but here goes…
I have an XML file that I want to read. Thus far, I have been using lxml.etree.ElementTree. However, I find that I need ...
0
votes
1answer
128 views
How to make lxml's iterparse ignore invalid XML charachters?
I have an XML with invalid characters.
LXML's XMLParser throws an exception on these invalid characters, but when I create XMLParser with recover=True option, it ignores the bad characters and works ...
0
votes
1answer
35 views
XML Tree traversal in python
I am traversing an XML file in Python like this:
for node in rootNode1.iter():
print node.tag
My output is:
Student
Int_Class_ID
Name
StudentID
EmailID
Address
Int_Class_ID
Street
City
...
0
votes
1answer
70 views
How to save “ą” in xml by python?
I have the following XML:
newX.xml
<?xml version="1.0" encoding="UTF-8"?>
<data>
<country name="Liechtenstein">
<neighbor name="Austriaą" direction="E"/>
...
0
votes
1answer
46 views
Python: get all content of specific XML tags
I have parsed a XML file and need to get all content from all <name> tags.
So far I've come up with this:
xml_tag = dom.getElementsByTagName('person')[0].toxml()
xml_data = ...
0
votes
2answers
123 views
XML File as Command-Line Argument and Parse in Python
I'm trying to parse the command-line argument in Python as follows:
python test.py /home/Desktop/test.xml
I've found getopt, but how does that work with three arguments? This source only shows 4, ...
0
votes
1answer
71 views
Python: Why will this string print but not write to a file?
I am new to Python and working on a utility that changes an XML file into an HTML. The XML comes from a call to request = urllib2.Request(url), where I generate the custom url earlier in the code, and ...
0
votes
2answers
23 views
Catching selected portion of xml files
My xml file is like this
<S_Row>
<S_Cell><S_CellBody></S_CellBody></S_Cell>
<S_Cell><S_CellBody></S_CellBody></S_Cell>
...
1
vote
2answers
102 views
Parsing and sorting keys in Python dictionary
I created the following dictionary:
code dictionary = {u'News; comment; negative': u'contradictory about news', u'News; comment': u'something about news'}
I now want to write some Python code that ...
0
votes
1answer
24 views
Parsing XML to match comments and text according to tag ids
(UPDATED): Added code to match values according to their ids. Question: Why are the matching ids u'1' and 'u'0' in both dictionaries not recognized?
(GOAL for Code):
I'm writing a script that takes ...
2
votes
1answer
133 views
Unicode Encoding Errors Python - Parsing XML can't encode a character (Star)
I am a beginner to Python and am currently parsing a web-based XML file from the eventful.com API however, I am receiving some unicode errors when retrieving certain elements of the data.
I am able ...
0
votes
2answers
256 views
Reading Web-Based XML file and parsing it in Python
I am very new to Python and GAE but I am attempting to download an XML file from the eventful.com api (in XML), parsing it and I will then storing this information within a database on Google Cloud ...
0
votes
1answer
61 views
Can Etree handle these kinds of XPath Queries
Can Pythons XML Parsing library Etree take complex XPath queries like the following?
# Note the "[text()=\"USER_4D\"]"
assert root.find("Group/EnvConfig/Overrides/Override/Key[text()=\"USER_4D\"]") ...
0
votes
1answer
76 views
lxml event parsing big file to extract only some data
I've seen quite a few questions here about lxml parsing and while they're all immensely useful, some problems are specific to the structure of the file being parsed.
In my case I have an xml which ...
0
votes
1answer
73 views
xml parsing error in python 2.6
Below is the script / function which parses the xml posted below. The code workes fine on python3 and when i ported to 2.6 ts giving below error
what could be the isuue here ?
Traceback (most recent ...
0
votes
1answer
51 views
Parsing multiple instance within a sentence in XML - Python
I have an xml file that has the following structure, where I have several instances within a sentence:
<corpus>
<text>
<sentence>
<instance\>
...
0
votes
2answers
74 views
Split specific items in list into two
I'm building an XML parser in python for an SVG file. It will eventually become specific instructions for stepper motors.
SVG files contain commands such as 'M', 'C' and 'L.' The path data might ...
0
votes
3answers
93 views
How to Parse a huge xml file (on the go) using Python
I have a huge xml file (the current wikipedia dump). This xml having a size of about 45 GB represents the entire data of the current wikipedia. The first few lines of the file are (output of more):
...
0
votes
1answer
56 views
Retrieving XML attribute values using Python iterparse
I'm trying to find out how to retrieve XML attribute values using the cElementTree iterparse in Python (2.7). My XML is something like this:
<root>
<record attr1="a" attr2="b" attr3="c" ...
0
votes
1answer
56 views
Reading an xml response and printing a required data in python
I have got an xml data as a output for my code. And Now I wanted to get an element value from the obtained xml data.
I have used following commands
data1 = r1.read()
dom = ...
1
vote
1answer
251 views
Python SVG parser
I want to parse an SVG file using python to extract coordinates/paths (I believe this is listed under the "path" ID, specifically the d="..."/>). This data will eventually be used to drive a 2 axis ...
0
votes
1answer
158 views
junk after document element: line 13, column 2
while parsing xml file,i am getting the following traceback
ParseError at /addxml/
junk after document element: line 13, column 2
Request Method: POST
Request URL: http://localhost:8000/addxml/
...