On 7/7/07, Stewart Stremler <[EMAIL PROTECTED]> wrote:
begin quoting Andrew Lentvorski as of Fri, Jul 06, 2007 at 10:21:40PM -0700: > Stewart Stremler wrote: > >begin quoting Andrew Lentvorski as of Fri, Jul 06, 2007 at 05:17:23PM > >-0700: > >>I don't know why everybody complains about XML. > >
[snip editor flames]
> >>You suck the whole tree into memory. You walk the tree. Done. > > > >You suck the whole tree into memory. You loop through an array of > >XPATH expressions, and store the result in a map. Done. You're right. > >It isn't that hard. > > Uh, what's this XPATH crap? You pull the tree directly into a series of > hierarchical maps directly. That's the DOM object. You still want data out... so you still need a key. And because it's in this big ugly DOM object, that key might as well be an XPath string. Key + DOM = value, done. You can also walk the DOM object and generate your own config object, but that gives you a two-step process where you end up handling every piece of data twice, and that conversion step is prone to error. Walking the DOM tree is painful, error-prone, and tedious. XPath greatly simplifies it... you work out the path to the data you want, once, and you suck it out.
Forget the DOM for 90% of what you do, especially for config files. Just walk the XML file once with SAX and load up your data structures. Fast, cheap, easy. http://sax.sourceforge.net/ BobLQ -- [email protected] http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list
