xerces-p-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Orsatti <orsa...@istar.fr>
Subject Create and writean XML file
Date Thu, 30 Oct 2003 14:25:38 GMT

Sorry to bother you again.
I am trying to create from sratch an XML file.
Base on the Xerces perl exemple (whichi seems to be old and not really 
running) and Xerces C++ ducumentation I write the following code:

#### Create a document
my $impl = 
my $serializer = $impl->createDOMWriter();

my $dt = eval{$impl->createDocumentType('contributors', '', 
error($@) if $@;
my $doc = eval{$impl->createDocument('contributors', 'contributors',$dt)};
error($@) if $@;

$serializer->setFeature("$XML::Xerces::fgDOMWRTFormatPrettyPrint", 1);

This line give me an error:
I can live without that but I wanted to try to have a nice ouput file.

my $root = $doc->getDocumentElement();

                  'Mike Pogue',

                  'Tom Watson',

                  'Susan Hardenbrook',
                  'tech writer',

my $str = $serializer->writeToString($root);

Here I would like to write to a file directly but I haven't found the 
equivanlent in Perl of the LocalFileFormatTarget  C++ class to use in 
writeNode() function.
But I can write my string to a file with Perl features.
By my string is all on one line:

<contributors xmlns="contributors"><person Role="manager"><name>Mike 

Role="tech writer"><name>Susan 

How can I format it with Xerces Perl in order to have an indented XML 
(has if is was written through emacs for example) ?
Is there better way to do what I want than the code I did ?
Thanks for you help

Take care


To unsubscribe, e-mail: xerces-p-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-p-dev-help@xml.apache.org

View raw message