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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:10:01+00:00 2026-06-06T10:10:01+00:00

I am using this line of code to get two data entries from an

  • 0

I am using this line of code to get two data entries from an XML file

perl xmlPerl.pl zbxml.xml "//zabbix_export/templates/template/items/item/name/text() | //zabbix_export/templates/template/items/item/description/text()"

Which takes the data, and displays it vertically. For example:

  • name1
  • description1
  • name2
  • description2

I used this in c# and had some code so that it would display like this

  • name1 – description1
  • name2 – description2
  • name3 – (blank since there
    isnt a description)

there were even some blanks in description. Here is the c# code, since it may help.

XPathExpression expr;
        expr = nav.Compile("/zabbix_export/templates/template/items/item/name | /zabbix_export/templates/template/items/item/description");
        XPathNodeIterator iterator = nav.Select(expr);

        //Iterate on the node set
        List<string> listBox1 = new List<string>();
        listBox1.Clear();
        try
        {
            while (iterator.MoveNext())
            {

                XPathNavigator nav2 = iterator.Current.Clone();
               // nav2.Value;
                listBox1.Add(nav2.Value);
                Console.Write(nav2.Value);
                iterator.MoveNext();
                nav2 = iterator.Current.Clone();
                Console.Write("-" + nav2.Value + "\n");

Well, I am having to switch it to Perl now, and I am not sure if I should try and find some Perl code to do what I need, or if this can be done in XPath? I tried looking at some w3 tutorials, but didn’t find what I was looking for.

Thanks!

edit –
would I need to edit this part of my xmlPerl.pl

# print each node in the list
foreach my $node ( $nodeset->get_nodelist ) {
print XML::XPath::XMLParser::as_string( $node ) . "\n";
}
  • 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-06T10:10:03+00:00Added an answer on June 6, 2026 at 10:10 am

    It cannot be done with an XPath. It can be done with an XSL transformation:

    <xsl:stylesheet 
      version="1.0" 
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
      <xsl:output method="text"/>
    
      <xsl:template match="text()"/>
    
      <xsl:template match="item">
        <xsl:value-of select="concat(name,' - ',description,'&#x0d;&#x0a;')"/>
      </xsl:template>
    
    </xsl:stylesheet>
    

    A simple Perl script that applies this XSLT will do the trick – see this for example (or any other command-line utility that applies an XSLT for that matter – like msxsl.exe)

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

Sidebar

Related Questions

I'm using this line of code to insert a value from an array into
How do I save an image file from data manipulated using image.load()? This is
I want to use this line of code: using (ADataContext _dc = new ADataContext(ConnectionString),
I tried using juggernaut cocoa: https://github.com/fpotter/juggernaut-cocoa Added this line to my code: JuggernautClient *client
I have a line, which is a sprite made by using this code CGPoint
I'm using this line to get the beginning time of the first day of
I've referenced System.Xml: using System.Xml; Then in this line: XmlDocument xdoc = new XmlDocument();
I am using ActiveRecord in Rails 3 to pull data from two different tables
I have a program that load data from a file using std::ifstream and store
I am using the following code to import data in Python: one=[] two=[] three=[]

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.