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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:31:47+00:00 2026-06-13T21:31:47+00:00

If solve is user , I need the value of name ( LINES ).

  • 0

If solve is user, I need the value of name (LINES).

if solve is imm and name is ARCH, I need the value of value (6M)

I tried in the following:

use strict;
use warnings;
use XML::LibXML;
my $parser = XML::LibXML->new();
my $doc = $parser->parse_file(...);
my $j = 0;
my @imm;
$imm[$j++] = $_->data
    foreach 
        $doc->findnodes(
            "//meters/meter"
            ."/name[../value[\@solve/string() = 'immediate']]"
            ."/text()");

Errors are

Possible unintended interpolation of @solve in string
Global symbol "@solve" requires explicit package name 

Sample XML:

<rules> 
      <meters>        
             <meter>
                   <name>LINES</spirit:name>
                   <display>LINES</display>
                   <description>Specifies the number of lines</description>
                   <value
                         solve="user"
                         id="LINES"
                         order="11"
                         format="long"
                         dataType="integer" 
                         min="2" 
                         max="34">34</value>
            </meter>
            <meter>
                  <name>ARCH</name>
                  <display>Define ARCH</display>
                  <description>Define ARCH</description>
                  <value 
                        format="string" 
                        solve="imm" 
                        id="ARCH" 
                        >6M</value>
             </meter>
       </meters>    
</rules>

<rules> 
      <meters>        
             <meter>
                   <name>LINES</spirit:name>
                   <display>LINES</display>
                   <description>Specifies the number of lines</description>
                   <value
                         solve="user"
                         id="LINES"
                         order="11"
                         format="long"
                         dataType="integer" 
                         min="2" 
                         max="34">34</value>
            </meter>
            <meter>
                  <name>ARCH</name>
                  <display>Define ARCH</display>
                  <description>Define ARCH</description>
                  <value 
                        format="string" 
                        solve="imm" 
                        id="ARCH" 
                        >6M</value>
             </meter>
       </meters>    
</rules>
  • 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-13T21:31:48+00:00Added an answer on June 13, 2026 at 9:31 pm

    This works for me:

    #!/usr/bin/perl
    use strict;
    use warnings;
    
    use XML::LibXML;
    
    my $parser = XML::LibXML->new();
    my $doc = $parser->parse_file('XXX.xml');
    my $j = 0;
    my @imm;
    $imm[$j++] = $_->data
        for $doc->findnodes(
                "//meters/meter"
                ."/name[../value[\@solve = 'imm']]"
                ."/text()");
    print for @imm;
    

    I made the following changes to your code:

    1. I removed the /string() part from the XPath expression. It is invalid usage of a function as indicated by the error I got.
    2. The value of solve is imm in your sample data, not immediate.

    BTW, changing the middle of the XPath expression to

    '/name[../value[@solve = "immediate"]]'
    

    avoids the need of the backslash.

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

Sidebar

Related Questions

Half the time I need to find a value based on string, their name,
I need to build app with user messages (dialogs). I've solved this problem by
I am attempting to solve Project Euler problem 10 where the user is asked
I have a problem that i cant solve :( I have a user control
I have a small app, where user can make some calculations and solve equations.
To solve some problem I need to compute a variant of the pascal's triangle
Scenarios I need to solve with task scheduler in Windows Server 2008: (#1) task
Say I have a class, User: public class User { private String name; private
I need to temporarily store the value in a PHP variable because the value
This application returns schoolmates of lawyers . When a user searches for first name

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.