ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-win32-users
perl-win32-users
XML Twig - perl
by Ganesh Babu Nallamothu other posts by this author
Sep 28 2004 11:53PM messages near this date
view in the new Beta List Site
RE: XML Twig - perl | Error in the Perl coding
Hello,

Using xml twig, I am trying to supply two elements in a line with the
separator tab.

Ex:
<c> 
<dl> 
ABC    CDE
add    eerwe
sdfsdfs    erewrwe
</dl> 
</c> 

Expected Result:
<c> 
<dl> 
<first> ABC</first><second>CDE</second>
<first> add</first><second>eerwe</second>
<first> sdfsdfs</first><second>erewrwe</second>
</dl> 
</c> 

Obtained Result:
<c> 
<dl> 
<first> ABC</first><second>CDE</second>
<first> add</first><second>eerwe</second>
<first> sdfsdfs</first><second>erewrwe</second>rwe
</dl> 
</c> 

i.e. After </second>  some characters are repeating, that character count is
equivalent to line count. If i give five lines between <dl>  and </dl>, then
five characters are repeating.

Can any one tell where am i going wrong?


Code Used:
my $t = new XML::Twig(
twig_handlers => 
{
"content"=> \&process_root
},
        pretty_print => 'nice',
       )-> parsefile("$ARGV[0]");

my $say=$t-> sprint;

print FOUT "$say";


sub process_root
{
 my ($a,$b,$c)=@_;
 my $bchild;
 for $bchild ($b-> children)
  {
    if  ($bchild-> tag eq 'dl')
        {
          $bchild=&dl($a,$bchild);
        }
   }
return $b;
}

sub dl
{
 my ($a,$b,$c)=@_;
 my $bchild;
if ($bchild-> text)
 {
   $bchild-> subs_text(
qr{(.+?)\t(.+?)\n},'&elt(first=> {},$1)&elt(second=>{},$2)');
}
return $b;
}

Thanks in advance,
Bhuvana


_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved