Dear Aleksandra, dear Folks,
On Thu, Oct 30, 2014 at 11:51:11AM +0000, Aleksandra Pawlik wrote:
> Hello!
>
> We are running an SWC course at Manchester as a part of a one week
> training for MSc students in Clinical Bioinformatics. We have 2.5 days
> for SWC and then the students will work on a small programming task in
> teams. The idea is that they will need to grab some XML files, parse
> them and then do some rather simple manipulation with the outputs.
>
> At the end of the SWC (we'll be using Python) we want to show them how
> to use a _simple_ library for XML. So before I dive into Google, I
> though I'd be lazy and ask the SWC community:
> 1) Has anyone created an SWC module on XML? If yes, can you point me to it?
> 2) Which Python library from XML would you recommend?
The standard xml.dom and xml.dom.minidom modules have so far been good
enough for my own basic XML hacking requirements. Here's a minimal
example for parsing some XML, adding an element and then writing it:
import sys
import xml.dom.minidom
x = u"""<?xml version="1.0" encoding="UTF-8"?>
<demo>
<title>some title</title>
<list>
<item>item from file</item>
</list>
</demo>
"""
d = xml.dom.minidom.parseString(x)
l = d.getElementsByTagName('list')[0]
e = d.createElement('item')
t = d.createTextNode('generated item')
e.appendChild(t)
l.appendChild(e)
d.writexml(sys.stdout)
Whether this is good enough for your course largely depends on what the
"rather simple manipulations" you aim for. If they're this simple I'd
run with these standard modules, they at least do have the advantage
that students won't have to faff around with installing additional
libraries if they want to revisit / build on what they've done in
the course.
Best regards & good luck / happy carpentering, Jan
> 3) Do you have any other suggestions?
>
> Before you jump on me saying "What the heck are you doing?Software
> Carpentry doesn't teach XML." I'll just say that the goal is _not_ to
> focus on XML. We want to show them how to use Python libraries. XML is
> an example and in the case of this particular audience, it is a better
> example than NumPy and SciPy (we had lots of discussions with prof.
> Andy Brass who runs the whole course). We will deliver the standard
> SWC but the remaining 2 days they are supposed to try flying on their
> own, working in groups writing a small program using what we taught
> them (structured programming, version control etc.)
>
> So, halp? Anyone?
>
> Many thanks.
> Aleksandra
>
> _______________________________________________
> Discuss mailing list
> [email protected]
> http://lists.software-carpentry.org/mailman/listinfo/discuss_lists.software-carpentry.org
--
+- Jan T. Kim -------------------------------------------------------+
| email: [email protected] |
| WWW: http://www.jtkim.dreamhosters.com/ |
*-----=< hierarchical systems are for files, not for humans >=-----*
_______________________________________________
Discuss mailing list
[email protected]
http://lists.software-carpentry.org/mailman/listinfo/discuss_lists.software-carpentry.org