"Lars Preben S. Arnesen" <[EMAIL PROTECTED]> writes:

> [ Jason E. Stewart ]
> 
> > > How do I parse a DOM Document? The document is read from file and
> > > then alterd interactivly by the user. Before I write it to file I'd
> > > like to verify that it's valid according to the dtd.
> > 
> > I would suggest only making valid changes to the file, and then you
> > don't have to validate it ;-)
> > 
> > Otherwise, you'll have to write it out as a file, and re-parse it. 
> 
> 
> Hrrrmmmm. The users are going to alter some attributes of
> DOM-elements. I don't want to check every attribute myself. That's why
> I use a XML parser... Writing the DOM tree to file and then read it is
> going to be a nasty hack since I cannot write the XML file (to it's
> final destination) unless it's valid. (I'm writing a script that
> generates a configuration file and it's critical that the
> configuration file valid at all times.)

I really think you're making a mistake. If you don't check the user's
input what are you supposed to do when they make a mistake? Are you
going to output the error from the parser saying: 'Invalid document'
--> not very helpful. 

But if you must:

Don't bother with a file, just use serialize() and write it to a
string, and then create a new DOMParser and use the MemBufInputSource
class to turn the string into an input source. See
t/MemBufInputSource.t for an example.

jas.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to