473,386 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Reading XML like Python!

I have to read a lot of XML for my upcoming project.
XML is hard on my eyes.
Is there some sort of converter that converts XML to something more
eye friendly? maybe like Python? I have seen restructured text. There
is a paper at EuroPython 2004 that seems to do something similar.

"Pythonic Alternatives for declarative XML-based specifications of
robot behavior"

Anyone know of any tools along these lines?

Thanks.
Jul 18 '05 #1
12 2023
In article <ba**************************@posting.google.com >,
jo*******@rediffmail.com (John) wrote:
I have to read a lot of XML for my upcoming project.
XML is hard on my eyes.
Is there some sort of converter that converts XML to something more
eye friendly? maybe like Python? I have seen restructured text. There
is a paper at EuroPython 2004 that seems to do something similar.

"Pythonic Alternatives for declarative XML-based specifications of
robot behavior"

Anyone know of any tools along these lines?

Thanks.


I had the same problem recently. I used the standard xml.dom.minidom
module to parse the XML, and about a page of Python code to pretty-print
it. Unfortunately, I'm not able to release the code, but if you're
familiar with how DOM works, you should be able to replicate it in under
an hour. If you're not familiar with DOM, it'll take you longer, but
it'll also give you a chance to get familiar :-)

Have you tried DAGS for "xml pretty-print"?
Jul 18 '05 #2
> I had the same problem recently. I used the standard xml.dom.minidom
module to parse the XML, and about a page of Python code to pretty-print
it. Unfortunately, I'm not able to release the code, but if you're
familiar with how DOM works, you should be able to replicate it in under
an hour. If you're not familiar with DOM, it'll take you longer, but
it'll also give you a chance to get familiar :-)

Have you tried DAGS for "xml pretty-print"?


I suppose I could write a simple parser myself but I was wondering if
this was a problem well solved by someone else already with all the
bells and whistles.

What is DAGS? A Google search came up with "Directed Acyclic Graphs".
Not being a CS guy, I am not sure about the relationship to pretty
printing. Any link?

Thanks.
Jul 18 '05 #3
John wrote:
I have to read a lot of XML for my upcoming project.
XML is hard on my eyes.
Is there some sort of converter that converts XML to something more
eye friendly? maybe like Python? I have seen restructured text. There
is a paper at EuroPython 2004 that seems to do something similar.


I used yaml - actually its not exactly what you asked for, but a different
way of producing markup, which is much more friendly to the eye, and as
whitespace is significant, resembles python in that respect. I'm not aware
of xml2yaml converters, but I haven't looked so there might be some.

--
Regards,

Diez B. Roggisch
Jul 18 '05 #4
"Diez B. Roggisch" <de*********@web.de> wrote in message news:<cl*************@news.t-online.com>...
John wrote:
I have to read a lot of XML for my upcoming project.
XML is hard on my eyes.
Is there some sort of converter that converts XML to something more
eye friendly? maybe like Python? I have seen restructured text. There
is a paper at EuroPython 2004 that seems to do something similar.


I used yaml - actually its not exactly what you asked for, but a different
way of producing markup, which is much more friendly to the eye, and as
whitespace is significant, resembles python in that respect. I'm not aware
of xml2yaml converters, but I haven't looked so there might be some.


Thanks for the info. I found some YAML and PYX converters on CPAN. Will do for now.
Jul 18 '05 #6
John wrote:
I have to read a lot of XML for my upcoming project.
XML is hard on my eyes.
Is there some sort of converter that converts XML to something more
eye friendly?


I don't know what your XML data is, but an XSLT stylesheet and xsltproc will
turn it into about anything you want.
Jul 18 '05 #7
bowman wrote:
I don't know what your XML data is, but an XSLT stylesheet and xsltproc will
turn it into about anything you want.


But if the OP thinks "XML is hard on my eyes" then
I suspect the stylesheet itself, written as it is in XML,
would be similarly hard on the eyes.

I know I don't like reading XSLT. Also in part because
I don't have much experience with functional programming
languages.

Andrew
da***@dalkescientific.com
Jul 18 '05 #8
jo*******@rediffmail.com (John) wrote in message news:<ba**************************@posting.google. com>...
I have to read a lot of XML for my upcoming project.
XML is hard on my eyes.
Is there some sort of converter that converts XML to something more
eye friendly? maybe like Python? I have seen restructured text. There
is a paper at EuroPython 2004 that seems to do something similar.

"Pythonic Alternatives for declarative XML-based specifications of
robot behavior"

Anyone know of any tools along these lines?

Thanks.


I am on a similar quest, for a notation that will let me write XSLT
without typing '<xsl:' a gazillion times. (And, more important, will
be easier to read.)

I have not made a choice yet, but Paul Tchistopolskii has assembled a
list of XML Alternatives at
http://www.pault.com/pault/pxml/xmlalternatives.html.

His own XSLScript looks promising for my project:
http://www.pault.com/pault/XSLScript/index.html

-- Wade Leftwich
Ithaca, NY
Jul 18 '05 #9
John <jo*******@rediffmail.com> pisze:
I have to read a lot of XML for my upcoming project.
XML is hard on my eyes.
Is there some sort of converter that converts XML to something more
eye friendly? maybe like Python?


effbot's ElementTree is a most pythonic API to XML documents I've ever
see.

--
Jarek Zgoda
http://jpa.berlios.de/ | http://www.zgodowie.org/
Jul 18 '05 #10
In article <ba**************************@posting.google.com >, John wrote:
I have to read a lot of XML for my upcoming project.
XML is hard on my eyes.
Is there some sort of converter that converts XML to something more
eye friendly? maybe like Python? I have seen restructured text. There
is a paper at EuroPython 2004 that seems to do something similar.

"Pythonic Alternatives for declarative XML-based specifications of
robot behavior"

Anyone know of any tools along these lines?


Check out xmlobject:

http://xmlobject.base-art.net/

Dave Cook
Jul 18 '05 #11
Dave Cook <da******@nowhere.net> wrote in message
Check out xmlobject:


I was looking for something exactly like this last week. Amazing how
much code it cuts out. Thanks for posting the link.
Jul 18 '05 #12
Kevin Dahlhausen wrote:
Dave Cook <da******@nowhere.net> wrote in message
Check out xmlobject:

I was looking for something exactly like this last week. Amazing how
much code it cuts out. Thanks for posting the link.


Other modules in the same category as XMLObject include:

- anobind http://www.xml.com/pub/a/2003/08/13/py-xml.html
- xmltramp: http://www.aaronsw.com/2002/xmltramp/
- gnosis.xml http://www.xml.com/pub/a/2003/07/02/py-xml.html

--
Mike
Jul 18 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Raymond Hettinger | last post by:
Found in a pamphlet at a pre-school: --------------------------------------- Reading improves vocabulary Reading raises cultural literacy through shared knowledge Reading develops writing skills...
4
by: Xah Lee | last post by:
# -*- coding: utf-8 -*- # Python # to open a file and write to file # do f=open('xfile.txt','w') # this creates a file "object" and name it f. # the second argument of open can be
0
by: travis ray | last post by:
Hi, I have an extension in which a file object is created in python and passed down to a c extension which attempts to read from it or write to it. Writing to the file pointer seems to work...
0
by: philip20060308 | last post by:
Hi all, Has anyone ever seen Python 2.4.1's httplib choke when reading chunked content? I'm using it via urrlib2, and I ran into a particular server that returns something that httplib doesn't...
1
by: Andrea Gavana | last post by:
Hello NG, that may sound a silly question, but I didn't find anything really clear about the issue of reading unformatted big endian files with Python. What I was doing till now, was using...
2
by: Jonathan Hunt | last post by:
Hi all, I have had a look on google/freshmeat etc. so please forgive me if I've missed an obvious answer. Can someone point me to a simple library to read/write ODF spreadsheets (i.e. ...
10
by: Tyler | last post by:
Hello All: After trying to find an open source alternative to Matlab (or IDL), I am currently getting acquainted with Python and, in particular SciPy, NumPy, and Matplotlib. While I await the...
42
by: psbasha | last post by:
Hi, Is it necessary in Python to close the File after reading or writing the data to file?.While refering to Python material ,I saw some where mentioning that no need to close the file.Correct me...
2
by: Benoit | last post by:
I got myself into programming late in the summer and have dabbled in python for the most part in that time, recently beginning work on a music player. In January, I start my minor in Information...
12
by: WaterWalk | last post by:
Hello. I wonder what's the effective way of figuring out how a piece of python code works. With C I often find it very useful to be able to run the code in step mode and set breakpoints in a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.