From: Paul Boddie <Paul.B<oddie@em...> - 2003-04-14 14:42:47
Aaron Held [mailto:aaron@...]:
["The path module is really cool." -> SQL]
> I think that at this level you should only return one value at a time.
> But then you would need another interface for searching....
I've been playing with XPath recently and with the right kind of database
schema information, it becomes possible to do stuff like this:
animals = xml.xpath.Evaluate("/zoo/cage/animal[@name = 'Simon']", doc)
This causes various queries to get invoked as the XPath engine explores a
DOM hierarchy which uses the database to populate its elements and
attributes. The result would be a collection of elements which represent the
information from the database as attributes, as in this example:
<species name='Giraffe' family='mammal'/>
Of course, relying on the XPath engine too much will result in some fairly
suboptimal querying - for example, the use of "//animal" in the above
example would actually cause the whole document to be searched. It would be
interesting to hear of standardised approaches which permit the XPath engine
to be a bit wiser about the DOM, in order to avoid such penalties.
Returning to the subject of paths, I've also been playing with an XPath
abstraction of filesystem paths:
files = xml.xpath.Evaluate("//*[@type = 'file']", doc)
Get latest updates about Open Source Projects, Conferences and News.