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 8182917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:00:14+00:00 2026-06-07T01:00:14+00:00

Here is a short XML file with 2 nodes having the same children (but

  • 0

Here is a short XML file with 2 nodes having the same children (but with 2 different values).

5000 for the node MIAMI

7777 for the node WASHINGTON

<country id="USA">
<city id="MIAMI" method="modify">
    <attributes>
        <number_people>5000</number_people>
        <average_income>40</average_income>
    </attributes>
</city>

<city id="WASHINGTON" method="modify">
    <attributes>
        <number_people>7777</number_people>
        <average_income>40</average_income>

    </attributes>
 </city>
</country>

Using Perl::Twig, I want to check if the nodes MIAMI and WASHINGTON are IDENTICAL (having the same children and the same values).

Here is what I did which is not working
($M->children eq $W->children) is found to be TRUE.
It should be false since “number_people” value is different.

#!/usr/bin/perl -w
use warnings;
use XML::Twig;

my $t= XML::Twig->new;
my $v= XML::Twig::Elt->new;

$t-> parsefile ('file.xml');
my $M=$t->first_elt('city');            # retrieve node MIAMI 
my $W=$M->next_sibling('city');    # retrieve node WASHINGTON


if ($M->children eq $W->children) {print "the two nodes are exactly IDENTICAL"; } 
  • 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-06-07T01:00:17+00:00Added an answer on June 7, 2026 at 1:00 am

    What’s about module Data::Compare, it help to compare two perl data structures recursively.

    I check documentation for module XML::Twig you can get structure of any TWIG object using method simplify. So $M->children->simplify

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML file that is very long, but here is a shot
I need to have my XSLT stylesheet sort my XML file's child nodes, but
Here is my schema and xml file contents. When I want to validate my
I am trying to access certain pieces of data from an xml file, here
Using Android, here is part of a layout xml file: <LinearLayout android:layout_width=fill_parent android:layout_height=wrap_content android:orientation=vertical
Here is a snippet from the XML file I am trying to parse: <Item
I have around 200K nodes and their relationship in a XML file as follows:
I have an XML file with a group of protein nodes, each one with
Something's screwy here. I'm trying to parse this XSL file: <?xml version=1.0 encoding=utf-8?> <xsl:stylesheet
Here is the short version. I have a Bonus Activity that has 25 image

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.