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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:47:09+00:00 2026-06-02T19:47:09+00:00

I am trying to parse the xml file which has collection of nested tags.I

  • 0

I am trying to parse the xml file which has collection of nested tags.I was trying with perl XML::Simple API to parse and individual tag values are parsed exactly but couldn able to parse the nested tag values .

<archetype>
    <original_language></original_language>
    <description></description>
    <archetype_id>
    <definition></definition>
    <ontology></ontology>
</archetype>

in the definition part contains the item details

example

<definition>
.
.
<node_id>at0004</node_id>
<attributes xsi:type="C_SINGLE_ATTRIBUTE">
<rm_attribute_name>value</rm_attribute_name>
+<existence> </existence>
<children xsi:type="C_DV_QUANTITY">
    <rm_type_name>DV_QUANTITY</rm_type_name>
    +<occurrences></occurrences>
    <node_id/>
    +<property></property>
    <list>
    <magnitude>
        <lower_included>true</lower_included>
        <upper_included>false</upper_included>
        <lower_unbounded>false</lower_unbounded>
        <upper_unbounded>false</upper_unbounded>
        <lower>0.0</lower>
        <upper>1000.0</upper>
</magnitude>
<units>mm[Hg]</units>
</list>
</children>
</attributes>
.
.
</definition>

From the above example file format i would like to filter the content like

node_id - > at0004
    magnitude -> lower -> 0.0
    magnitude -> higher -> 1000.0

please guide me to filter the content.

  • 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-02T19:47:13+00:00Added an answer on June 2, 2026 at 7:47 pm

    You need to learn about references: perlreftut, perlref, perldsc.

    use strictures;
    use XML::Simple qw(:strict);
    
    my $root = XMLin(<<'XML', ForceArray => 0, KeyAttr => undef);
    <definition>
    .
    .
    <node_id>at0004</node_id>
    <attributes xsi:type="C_SINGLE_ATTRIBUTE">
    <rm_attribute_name>value</rm_attribute_name>
    +<existence> </existence>
    <children xsi:type="C_DV_QUANTITY">
        <rm_type_name>DV_QUANTITY</rm_type_name>
        +<occurrences></occurrences>
        <node_id/>
        +<property></property>
        <list>
        <magnitude>
            <lower_included>true</lower_included>
            <upper_included>false</upper_included>
            <lower_unbounded>false</lower_unbounded>
            <upper_unbounded>false</upper_unbounded>
            <lower>0.0</lower>
            <upper>1000.0</upper>
    </magnitude>
    <units>mm[Hg]</units>
    </list>
    </children>
    </attributes>
    .
    .
    </definition>
    XML
    
    my $m = $root->{attributes}{children}{list}{magnitude};
    printf <<'TEMPLATE', $root->{node_id}, $m->{lower}, $m->{upper};
    node_id -> %s
        magnitude -> lower -> %.1f
        magnitude -> higher -> %.1f
    TEMPLATE
    
    use Data::Dump::Streamer qw(Dump); Dump $root;
    

    Output:

    node_id -> at0004
        magnitude -> lower -> 0.0
        magnitude -> higher -> 1000.0
    
    $HASH1 = {
        attributes => {
            children => {
                content => [("\n    +") x 2],
                list    => {
                    magnitude => {
                        lower           => '0.0',
                        lower_included  => 'true',
                        lower_unbounded => 'false',
                        upper           => '1000.0',
                        upper_included  => 'false',
                        upper_unbounded => 'false'
                    },
                    units => 'mm[Hg]'
                },
                node_id      => {},
                occurrences  => {},
                property     => {},
                rm_type_name => 'DV_QUANTITY',
                "xsi:type"   => 'C_DV_QUANTITY'
            },
            content           => "\n+",
            existence         => {},
            rm_attribute_name => 'value',
            "xsi:type"        => 'C_SINGLE_ATTRIBUTE'
        },
        content => [("\n.\n.\n") x 2],
        node_id => 'at0004'
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to parse this xml file, which has some nested nodes. I
Hi I am trying to Parse a local xml file (which has database table
I'm trying to parse an xml file that has the contents of a simple
I am Trying To Use NSXMLParser to parse an xml file using cocoa which
I'm trying parse the follow XML file: <root>Root <pai>Pai_1 <filho>Pai1,Filho1</filho> <filho>Pai1,Filho2</filho> </pai> <pai>Pai_2 <filho>Pai2,Filho1</filho>
I'm trying to parse an xml file with PHP. I'm using this code and
I am trying to parse an XML file in java, after I have to
I am trying to parse an XML file into smaller XML files and place
So I'm trying to parse an xml file: <?xml version=1.0 encoding=utf-8 ?> <Root> <att1
I am beginner in PHP. I am trying to parse this xml file. <relationship>

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.