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

  • Home
  • SEARCH
  • 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 5957653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:25:55+00:00 2026-05-22T18:25:55+00:00

$ xmlstarlet sel -t -c //str[@name=id and .=http://localhost:8080/index.html]/../str[@name=doc-norm]/value results.xml My understanding is that xmlstarlet

  • 0
$ xmlstarlet sel -t -c "//str[@name="id" and .="http://localhost:8080/index.html"]/../str[@name="doc-norm"]"/value results.xml

My understanding is that xmlstarlet doesn’t fully support xpath expressions. Is there any other command-line tool that does BTW?

<doc>
    <str name="id">http://localhost:8080/index.html</str>
    <str name="doc-norm">6</str>
</doc>
  • 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-22T18:25:56+00:00Added an answer on May 22, 2026 at 6:25 pm

    Are you trying to return the 6 from your example?

    I don’t have xmlstarlet to test this on, but try this XPath:

    //*[str[@name='id']='http://localhost:8080/index.html']/str[@name='doc-norm']

    This should return the value of a str element that has a name attribute with a value of doc-norm when its parent element has a child str element that has an id attribute with a value of http://localhost:8080/index.html. (I hope that makes sense!)

    I should also add that if you know what the level of the parent element is, try to avoid using the //. Something like /doc[str[@name='id']='http://localhost:8080/index.html']/str[@name='doc-norm'] would be more efficient.

    UPDATE

    I downloaded xmlstartlet to test and it works fine, however it returns the entire str element. If you want the text only, add text() to the end of the XPath:

    //*[str[@name='id']='http://localhost:8080/index.html']/str[@name='doc-norm']/text()

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

Sidebar

Related Questions

Here I'm selecting the node: $ xmlstarlet sel -t -c /configuration/property[name='http.agent.name']/value conf/nutch-default.xml <value/> This
I'm looking for solution to extract some node from large xml file (using xmlstarlet
I have the following XML: <?xml version=1.0 encoding=UTF-8?> <test-report> <testsuite> <test name=RegisterConnection1Tests> <testcase name=testRregisterConnection001></testcase>
I need to read some filenames from an xml config file using xmlstarlet with
Let's say I have the following XML file <a id=123> <b type=foo value=1 />
given this xml as example: <epp:phrases xmlns=http://www.w3.org/1999/xhtml xmlns:epp=http://eprints.org/ep3/phrase xmlns:epc=http://eprints.org/ep3/control> <epp:phrase id=Plugin/Screen/BatchEdit:title>Batch Editing Tool</epp:phrase> <epp:phrase
Versions of XMLStarlet found in current Linux distributions have a limit of 128 operations
I have a typical pom.xml, and want to print the groupId, artifactId and version,
I have a file that keeps appending the following xml. What I want to
Hmmmm ... Although it works in most cases, one column has html data in

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.