minidom

Converting a Doc object into a string in python

I'm using minidom to parse through an xml document. I took the data with yum tags and stored them in a list and calculated the frequency of the words. However, its not storing or reading them as strings in the list. Is there another way to do it? Right now this is what I have: yumNodes = [node for node in doc.getElementsByTagName("yum")...

Decoding not reversing unicode encoding in Django/Python

Ok, I have a hardcoded string I declare like this name = u"Par Catégorie" I have a # -- coding: utf-8 -- magic header, so I am guessing it's converted to utf-8 Down the road it's outputted to xml through xml_output.toprettyxml(indent='....', encoding='utf-8') And I get a UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3...

stop minidom converting < > to &lt; &gt;

Im trying to output some data from my google app engine datastore to xml so that a flash file can read it, The problem is when using CDATA tags the outputted xml contains &lt; instead of < e.g <name>&lt;![CDATA][name]]&gt;</name> here is my python which outputs the xml: doc = Document() feed = doc.createElement("feed") ...

python xml.dom.minidom.Attr question

Getting attributes using minidom in Python, one uses the "attributes" property. e.g. node.attributes["id"].value So if I have <a id="foo"></a>, that should give me "foo". node.attributes["id"] does not return the value of the named attribute, but an xml.dom.minidom.Attr instance. But looking at the help for Attr, by doing help('xml.do...

Get node name with minidom

Is it possible to get the name of a node using minidom? for example i have a node: <heading><![CDATA[5 year]]></heading> what i'm trying to do is store the value heading so that i can use it as a key in a dictionary, the closest i can get is something like [<DOM Element: heading at 0x11e6d28>] i'm sure i'm overlooking something v...

Integers in TextNodes w/ Python minidom

I am working on an API using SOAP and WSDL. The WSDL expects integers to come through. I am fairly new to ALL of this, and constructing XML in Python. I have chosen to use minidom to create my SOAP message. So using minidom, to get a value into a node I found I have to do this: weight_node = xml_file.createElement("web:Weight") weight...

XML - python prints extra lines

`from xml import xpath from xml.dom import minidom xmldata = minidom.parse('model.xml').documentElement for maks in xpath.Evaluate('/cacti/results/maks/text()', xmldata): print maks.nodeValue ` and I get result: 85603399.14 398673062.66 95785523.81 But I needed to be: 85603399.14 NO SPACE 398673062.66 NO SPACE 95785523.81...

Hudson XML error-- No module named dom.minidom

I am trying to send a simple XML file of the format given in http://wiki.hudson-ci.org/display/HUDSON/Monitoring+external+jobs . I was able to send it easily and was getting desired result!! Then I tried to build this XML file using python script and it was giving me the exact file that I wanted without any problem. But when I tried to r...

xml.dom.minidom.parse() in Jython gives an error for XML files with <?xml... and <!DOCTYPE tags

It works fine as long as the XML files don't have <?xml version="1.0" encoding="UTF-8"?> and the DOCTYPE tags. I would switch to xml.etree but I already wrote quite a lot of code using minidom. The same thing works in Python. It sounds like a bug in Jython's minidom, but is there a way to work around it? ...

Using Python to scrape DataSet and Query data from RDL

I set out today with the intent to parse an SSRS RDL file (XML) using Python in order to gather the DataSet and Query data. A recent project has me back tracking on a variety of reports and data sources with the intention of consolidating and cleaning up what we have published. I was able to use this script to create a CSV file with th...

XML parsing in Python

Having trouble getting this to work. What's strange is that I have 10 bookmarks in Delicious and it prints out 10 blank strings so it must be close to working. import urllib from xml.dom.minidom import parse FEED = 'http://feeds.delicious.com/v2/rss/migrantgeek' dom = parse(urllib.urlopen(FEED)) for item in dom.getElementsByTagName('...

Using urllib and minidom to fetch XML data

I'm trying to fetch data from a XML service... this one. http://xmlweather.vedur.is/?op_w=xml&amp;type=forec&amp;lang=is&amp;view=xml&amp;ids=1 I'm using urrlib and minidom and i can't seem to make it work. I've used minidom with files and not url. This is the code im trying to use xmlurl = 'http://xmlweather.vedur.is' xmlpath = xml...

Write element value to an XML in Python

HI, I have a Text file containing a key=value pairs. I have another XML file which contains the "key" as "Source" Node and "value" as "Destination Node". <message> <Source>key</Source> <Destination>value</Destination> </message> Suppose, I get a new text file containing the same keys but different values, how do I go about chan...

Parsing document with python minidom

I have the following XML document that I have to parse using python's minidom: <?xml version="1.0" encoding="UTF-8"?> <root> <bash-function activated="True"> <name>lsal</name> <description>List directory content (-al)</description> <code>ls -al</code> </bash-function> <bash-function activated="True"...

How do you generate xml from non string data types using minidom?

How do you generate xml from non string data types using minidom? I have a feeling someone is going to tell me to generate strings before hand, but this is not what I'm after. from datetime import datetime from xml.dom.minidom import Document num = "1109" bool = "false" time = "2010-06-24T14:44:46.000" doc = Document() Submission = d...