minidom nodes without a document?
Magnus Lie Hetland
mlh at furu.idi.ntnu.no
Mon Nov 24 11:10:18 EST 2003
More information about the Python-list mailing list
Mon Nov 24 11:10:18 EST 2003
- Previous message (by thread): minidom nodes without a document?
- Next message (by thread): minidom nodes without a document?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
In article <8b5e42a6.0311231738.6376d486 at posting.google.com>, Levente Sandor wrote: >mlh at furu.idi.ntnu.no (Magnus Lie Hetland) wrote in message >news:<slrnbs23vn.q61.mlh at furu.idi.ntnu.no>... >> Is it possible to build a minidom tree bottom-up without access to a >> document node? It seems that simply instantiating the various node >> classes doesn't quite do the trick... > >I'm not sure what you mean exactly by "without access to...". You need >a Document instance to create the elements, but they aren't added >automatically to it. > [snip] Right. I understand this. Thanks to you and Martin for mentioning it, though :) My problem is that I'm building the DOM as part of a bottom-up parse, where the various subtrees are build independently from each other, through callbacks that are set as part of the parser. So... For all of these to have access to a document object (so they can use the createFoo methods) I'd have to either (1) hard-code a document into the parser (meaning, basically, that each parser instance can only be used once), or (2) refactor the parser to supply a context object to each callback (which could be, for example, the document object). I guess the latter is the way to go, but it does seem awkward that it should be necessary. In my case it's OK, as the parsing code is part of my project, but if I used an external parser, I'd have to create a separate AST and then translate that into a DOM tree afterward; a bit unnecessary... Oh, well. Can't argue with the DOM, I suppose :) -- Magnus Lie Hetland "In this house we obey the laws of http://hetland.org thermodynamics!" Homer Simpson
- Previous message (by thread): minidom nodes without a document?
- Next message (by thread): minidom nodes without a document?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list