Hi, On Thu, Oct 30, 2014 at 10:13 AM, Andrew Walker [EAR] <[email protected]> wrote: > If the lesson should be applicable to a wider range of documents I think > BeautifulSoup is probably the way to go. If the idea is to learn about the > details of XML I would probably start with an exercise using XPath and try to > focus on the subset that is supported by ElementTree (leaving the choice of > ElementTree and lxml as a detail for now). > > I can probably find the documentation for the old XPath exercises if they > will be useful.
Indeed--regardless of what library(ies) you look at I would second teaching basic XPath as a way to query information from existing XML documents. Obviously you need to move beyond that when it comes to parsing entire documents into some data structure that can be worked with programmatically and written back out as XML. But XPath is a nice place to start and pretty useful on its own. On Thu, Oct 30, 2014 at 8:53 AM, Raniere Silva <[email protected]> wrote: > What about using JSON or YAML instead of XML? I don't want to raise a flame > war > about file formats but Python's Standard JSON library [1] and PyYAML [2], in > case you want use a third party library for your example, is very good for > examples. I think this is probably a case of having to teach XML as it is already used as the dominant format for some domain-specific data. That's fine--people working with it need to understand how to do XML The Right Way. I recently reviewed some code that was supposed to be working on XML and was using regular expressions to parse it and printf statements to write it out. Point being, to this day not everyone in the world knows how to work with XML :) Erik _______________________________________________ Discuss mailing list [email protected] http://lists.software-carpentry.org/mailman/listinfo/discuss_lists.software-carpentry.org
