&#10 is the linebreak your input contains, since you are read the
output of a command into @myNames with the backtick operator.

If you say "chomp;" inside your foreach loop, you'll be rid of the linebreaks.

2010/7/14 Barih Uri <[email protected]>
>
>
> Hi Shmuel.& all members
> THX for your answer but the first development defintion was to create XML 
> without the xml version .
>
> Continue my first question I complete my perl script (showing down) but I 
> have another critical two questions
>
> The following perl need need to create XML file as the following:
>
>
>
> example 1
>
> <LEVEL1>
> <LEVEL2>
>   <LEVEL3>
>   <UnitType Name="TEST" UponError="Stop" ExecutionOrder="1" />
>   <UnitType Name="TEST1" UponError="Stop" ExecutionOrder="1" />
>   <UnitType Name="TEST2" UponError="Stop" ExecutionOrder="1" />
>   </LEVEL3>
> </LEVEL2>
> </LEVEL1>
>
>
>
>
> But the real XML file that created after I run my perl script displayed as 
> the following: -:(
>
>
> <LEVEL1><LEVEL2><LEVEL3><UnitType Name="TEST1&#10;" UponError="Stop" 
> ExecutionOrder="1"/><UnitType Name="TEST2&#10;" UponError="Stop
> " ExecutionOrder="1"/><UnitType Name="TEST&#10;" UponError="Stop" 
> ExecutionOrder="1"/></LEVEL3></LEVEL2></LEVEL1>
>
>
>
> QUESTIONS:
>
> 1. The question what I need to change in the perl script in order to create 
> XML file as example 1
> 2. the second question is why I get the characters "&#10" after TEST word , 
> according to perl script @myNames need to get all files that have FILE.xml 
> and cut the file name until the name FILE
>
> Thanx for your help
> Uri & yael
>
>
>
>
> ######################################################################################################################################
> My perl script:
> ######################################################################################################################################
>
> #!/usr/bin/perl
>
> use warnings;
> use XML::LibXML;
>
> local $XML::LibXML::skipXMLDeclaration = 1;
>
> my $doc  = XML::LibXML::Document->new;
> my $root = $doc->createElement('LEVEL1');
> $doc->setDocumentElement($root);
>
> my $system = $doc->createElement('LEVEL2');
> $root->appendChild($system);
>
> my $install = $doc->createElement('LEVEL3');
> $system->appendChild($install);
>
> my @myNames=` ls /var/tmp | grep FILE.xml | sed "s/.FILE.*//"  `;
>
> foreach (@myNames) {
>
> my $objVar = $doc->createElement('UnitType');
> $install->appendChild($objVar);
> $objVar->setAttribute('Name' , $_ );
> $objVar->setAttribute('UponError' , Stop );
> $objVar->setAttribute('ExecutionOrder' , 1 );
> }
>
> open (MYFILE, '>data.xml');
> print   MYFILE  $doc->toString;
> close (MYFILE);
>
>
>
> Hi Uri.
>
> Barih Uri wrote:
> > Actually I not need the title "*<?xml** **version="1.0"?>*"
> > All I want is to create XML DOM as the following
>
> I would recommend that you leave this title alone. it identify the file as 
> "proper" xml, and is standard in all xml files.
> Unless you are moving this data afterwards on a very limited communication 
> channel, just let it stay.
>
> Shmuel.
> _______________________________________________
> Perl mailing list
> [email protected]
> http://mail.perl.org.il/mailman/listinfo/perl
>
>   ________________________________
> “This e-mail message may contain confidential, commercial or privileged 
> information that constitutes proprietary information of Comverse Technology 
> or its subsidiaries. If you are not the intended recipient of this message, 
> you are hereby notified that any review, use or distribution of this 
> information is absolutely prohibited and we request that you delete all 
> copies and contact us by e-mailing to: [email protected]. Thank You.”
>
> _______________________________________________
> Perl mailing list
> [email protected]
> http://mail.perl.org.il/mailman/listinfo/perl



--
Gaal Yahas <[email protected]>
http://gaal.livejournal.com/
_______________________________________________
Perl mailing list
[email protected]
http://mail.perl.org.il/mailman/listinfo/perl

Reply via email to