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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:05:40+00:00 2026-06-08T03:05:40+00:00

I have an XML file containing texts in some languages. I want to extract

  • 0

I have an XML file containing texts in some languages. I want to extract the texts in just one language and store them in a separate file. How can I do this?
Here is some of the beginning lines of my file:

<?xml version="1.0" encoding="UTF-8"?>
<tmx version="1.4b">
  <header creationtool="ORESAligner" creationtoolversion="1.0" datatype="plaintext" segtype="paragraph" adminlang="en-us" srclang="EN" o-tmf="ORES"/>
  <body>
    <tu tuid="55_100:6">
      <prop type="session">55</prop>
      <prop type="committee">3</prop>
      <tuv xml:lang="EN">
        <seg>RESOLUTION 55/100</seg>
      </tuv>
      <tuv xml:lang="AR">
        <seg>القرار 55/100</seg>
      </tuv>
      <tuv xml:lang="ZH">
        <seg>第55/100号决议</seg>
      </tuv>
      <tuv xml:lang="FR">
        <seg>RÉSOLUTION 55/100</seg>
      </tuv>
      <tuv xml:lang="RU">
        <seg>РЕЗОЛЮЦИЯ 55/100</seg>
      </tuv>
      <tuv xml:lang="ES">
        <seg>RESOLUCIÓN 55/100</seg>
      </tuv>
    </tu>
  </body>
</tmx>

Now say I want just English texts. the desired output should be:

RESOLUTION 55/100

How should I use this script? I am newbie in working XML files, and don’t know how can I use this XPath expression. As I know xmlstarlet is able to modify XML files. But I don’t know how…?

  • 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-08T03:05:41+00:00Added an answer on June 8, 2026 at 3:05 am

    Extract English Nodes with XmlStarlet

    You could use xmlstarlet to query your XML using XPath, and return just the nodes with an English-language attribute. For example:

    $ xmlstarlet sel -t -v "//tuv[@xml:lang='EN']/seg/text()" /tmp/foo
    RESOLUTION 55/100
    

    Store Node Values in a File with Language Extension

    If you want to store those values in some language-based file, then you could dump the values of each node found into a file with a language-based extension (e.g. “EN” for English).

    # Don't overwrite LANG; use some other variable.
    language='EN'
    
    xmlstarlet sel \
        --noblanks \
        --text \
        --template \
        --match "//tuv[@xml:lang='${language}']" \
        --value-of seg \
        -n \
        /tmp/foo > "/tmp/foo.$language"
    

    With this example, the contents of all matching nodes will be written to /tmp/foo.EN for further processing. You can certainly adjust the shell redirection to suit any additional requirements.

    • 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 containing some scientific text that I want to display
I have an XML file with texts in a certain language and I need
I have a XML file containing metadata like a field's maximum length. I have
I have an HTML file containing these lines - <script>PrintFileURL("13572_BranchInformationReport_2012-06-29.xml","13572_BranchInformationReport_2012-06-29.zip",0,"184277","Jun 29 1:30","/icons/default.gif")</script> <script>PrintFileURL("13572_BranchInformationReport_2012-07-02.zip","13572_BranchInformationReport_2012-07-02.zip",0,"184302","Jul 2
I have an XML file from which I am parsing some content to display
I have an XML file containing seed data that I'm trying to load into
I have a large (~50Mb) file containing poorly formatted XML describing documents and properties
I have a simple text file containing some CSV with the following structure: @Parent1_Field1,
So I have an xml file containing ... <chapter> <para>This line has a quote
In C#, assume that I have an XElement (say myXElement ) containing some XML

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.