[XML-SIG] xmlpickle.py ?!
M.-A. Lemburg
mal@lemburg.com
Wed, 09 Aug 2000 10:01:24 +0200
uche.ogbuji@fourthought.com wrote:
>
> > BTW, how would one access "Mike" in this XML file without reverting to
> > positional indexing ?
> >
> > <dictionary>
> > <item>
> > <key>Mike</key>
> > <value><address>1234 Main Street</address></value>
> > </item>
> > </dictionary>
>
> Hmm? No positional indexing neede, I'd think:
>
> xml.xpath.Evaluate('string(/dictionary/item/key)')
>
> would return "Mike".
>
> Maybe I misunderstand you.
What happens if your dictionary has 100 entries and you
want to lookup "Mike" (which is stored as content of key) ?
And once you've found it, how would you get at the corresponding
value ?
Sorry for my ignorance shining through here. I should
really read the XPath specs... ALAS, no time for this now.
> > It seems that these XPath lookups have to be context senstive...
>
> They do, but how does that imply "positional indexing"?
Well, I guess sometimes you'd have to look ahead (in terms of
structure depth) to find the right tag and then back out
again to read the container as a whole, e.g. in the above
case the item.
Thanks,
--
Marc-Andre Lemburg
______________________________________________________________________
Business: http://www.lemburg.com/
Python Pages: http://www.lemburg.com/python/