Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6855893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:48:57+00:00 2026-05-27T01:48:57+00:00

sorry for asking again and again, because lack of knowledge in perl and I

  • 0

sorry for asking again and again, because lack of knowledge in perl and I am new to programming language.
my actual problem is I am extracting some nodes from several files and storing in a string and in that string I have some repeated strings so I need to delete repeated strings. so I tried after your suggestion like this.

#!/usr/bin/perl
use warnings;
use strict;
use XML::LibXML;
use Carp;
  use File::Find;
use File::Spec::Functions qw( canonpath );
use XML::LibXML::Reader;

my @ARGV ="c:/main/work";die "Need directories\n" unless @ARGV;
my $all="<DTCSpecification xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n";
  find(
       sub {
    return unless ( /(_tr\.xml)$/ and -f );
    extract_information();
    return;
    },
  @ARGV
  );
 my $elem;
 sub extract_information {
    my $path = $_;

  if ( my $reader = XML::LibXML::Reader->new( location => $path )) {

         while ( $reader->nextElement( 'university' )) {
                  $elem = $reader->readOuterXml();
         $all=$all.$elem;
        }
   }
    return;
    }
  my $so="</DTCSpecification>";
  $all= $all.$so;

  my $doc = XML::LibXML->load_xml( string=>$all);
  my %seen;
    foreach my $uni ( $doc->findnodes('//university') ) 

     my $name = $uni->find('Code');

    print "'$name' duplicated\n",
    $uni->unbindNode() if $seen{$name}++;  # Remove if seen before
     }
   $all = $all.$doc->toString;
    print $all;

it printing two times first time with repeated information and second time with without repeated. I tried so much but I can’t understanding why its printing two times.how to eliminate printing with repeated information. and also it is removing nodes according to element “code” so its removing node when the code element occurred second time, but some times I have useful information in second one not at the first appearance. How should I overcome this. could you help me. I am very very sorry for asking again and again and wasting your valuable time.its my humble request.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:48:58+00:00Added an answer on May 27, 2026 at 1:48 am

    It’s not clear why XML::LibXML::Reader is needed here. Perhaps a little more information would help in this regard.

    Here’s how I would do it though:

    use strict;
    use warnings;
    use XML::LibXML;
    
    my $file = 'universities.xml';
    my $doc = XML::LibXML->load_xml( location => $file );
    
    my %seen;
    foreach my $uni ( $doc->findnodes('//university') ) {  # 'university' nodes only
    
        my $name = $uni->find('name');
    
        print "'$name' duplicated\n",
          $uni->unbindNode() if $seen{$name}++;  # Remove if seen before
    }
    
    $doc->toFile('universities.xml'); # Print to file
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry for asking it again, there are already some questions about this keyword. But
Sorry for asking this again but ppl seem to connect csrf only with form
Sorry for asking such a vague question, i'm new to using C# / ASP.NET.
Sorry for asking a rather n00b question, I am rather new to ASP.NET MVC.
I am new to Cstring, sorry for asking dumb question, please help. char string[10];
sorry i'm asking this again, but I can't find a solution. I know there
sorry for asking this question again but i didnt get much help on the
Sorry to be asking such similar question again, I am trying to read the
Sorry for asking this question as it may be asked some times around the
Sorry for asking such a question again. I've been looking for a solution for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.