Extract select match value of same contents in XML fileText processing: convert text of table of content into djvu bookmark format?Clean up concatenated XML filesHow to remove a line from a tag in shell script?Extract value from XMLGrep only those lines with “<active>…</active>” whose next line contains specific tag and valueextract xml tag value from the file to Variableneed to join only certain lines of a xml file togetherExtract value from XML file using shell scriptSED remove spaces and line breaksHow to extract selected value in XML

Paid for article while in US on F1 visa?

Arrow those variables!

Mutually beneficial digestive system symbiotes

How do I gain back my faith in my PhD degree?

Today is the Center

What typically incentivizes a professor to change jobs to a lower ranking university?

Why is 150k or 200k jobs considered good when there's 300k+ births a month?

Important Resources for Dark Age Civilizations?

How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?

How much of data wrangling is a data scientist's job?

Can the number of solutions to a system of PDEs be bounded using the characteristic variety?

Took a trip to a parallel universe, need help deciphering

Are astronomers waiting to see something in an image from a gravitational lens that they've already seen in an adjacent image?

Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?

if condition in the past

dbcc cleantable batch size explanation

Could gravitational lensing be used to protect a spaceship from a laser?

Is it inappropriate for a student to attend their mentor's dissertation defense?

Why "Having chlorophyll without photosynthesis is actually very dangerous" and "like living with a bomb"?

Operational amplifier as comparator at high frequency

Why does Kotter return in Welcome Back Kotter?

Were any external disk drives stacked vertically?

How old can references or sources in a thesis be?

Question relative to pads for capacitors - high frequency



Extract select match value of same contents in XML file


Text processing: convert text of table of content into djvu bookmark format?Clean up concatenated XML filesHow to remove a line from a tag in shell script?Extract value from XMLGrep only those lines with “<active>…</active>” whose next line contains specific tag and valueextract xml tag value from the file to Variableneed to join only certain lines of a xml file togetherExtract value from XML file using shell scriptSED remove spaces and line breaksHow to extract selected value in XML






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I using this command for below xml file.



xmlstarlet sel -t -v '//channel[protected = "True"]/playlist_url' -nl file.xml


and result;



host.net/aa/vodpr
host.net/aa/vodpr/con_tv_r.php


Can I choose a line in result? Example only last line or 2. line?



<?xml version="1.0" encoding="UTF-8" ?>
<items>

<channel>
<title><![CDATA[*** variable text ***]]></title>
<playlist_url><![CDATA[http://host.net/aa/15_info/]]></playlist_url>
</channel>

<channel>
<title><![CDATA[*** variable text ***]]></title>
<playlist_url><![CDATA[http://host.net/aa/16_info/]]></playlist_url>
</channel>

<channel>
<title><![CDATA[*** variable text ***]]></title>
<playlist_url><![CDATA[http://host.net/aa/vodpr/]]></playlist_url>
<protected>True</protected>
</channel>

<channel>
<title><![CDATA[*** variable text ***]]></title>
<playlist_url><![CDATA[http://host.net/aa/vodpr/con_tv_r.php]]></playlist_url>
<protected>True</protected>
</channel>

</items>









share|improve this question




























    0















    I using this command for below xml file.



    xmlstarlet sel -t -v '//channel[protected = "True"]/playlist_url' -nl file.xml


    and result;



    host.net/aa/vodpr
    host.net/aa/vodpr/con_tv_r.php


    Can I choose a line in result? Example only last line or 2. line?



    <?xml version="1.0" encoding="UTF-8" ?>
    <items>

    <channel>
    <title><![CDATA[*** variable text ***]]></title>
    <playlist_url><![CDATA[http://host.net/aa/15_info/]]></playlist_url>
    </channel>

    <channel>
    <title><![CDATA[*** variable text ***]]></title>
    <playlist_url><![CDATA[http://host.net/aa/16_info/]]></playlist_url>
    </channel>

    <channel>
    <title><![CDATA[*** variable text ***]]></title>
    <playlist_url><![CDATA[http://host.net/aa/vodpr/]]></playlist_url>
    <protected>True</protected>
    </channel>

    <channel>
    <title><![CDATA[*** variable text ***]]></title>
    <playlist_url><![CDATA[http://host.net/aa/vodpr/con_tv_r.php]]></playlist_url>
    <protected>True</protected>
    </channel>

    </items>









    share|improve this question
























      0












      0








      0








      I using this command for below xml file.



      xmlstarlet sel -t -v '//channel[protected = "True"]/playlist_url' -nl file.xml


      and result;



      host.net/aa/vodpr
      host.net/aa/vodpr/con_tv_r.php


      Can I choose a line in result? Example only last line or 2. line?



      <?xml version="1.0" encoding="UTF-8" ?>
      <items>

      <channel>
      <title><![CDATA[*** variable text ***]]></title>
      <playlist_url><![CDATA[http://host.net/aa/15_info/]]></playlist_url>
      </channel>

      <channel>
      <title><![CDATA[*** variable text ***]]></title>
      <playlist_url><![CDATA[http://host.net/aa/16_info/]]></playlist_url>
      </channel>

      <channel>
      <title><![CDATA[*** variable text ***]]></title>
      <playlist_url><![CDATA[http://host.net/aa/vodpr/]]></playlist_url>
      <protected>True</protected>
      </channel>

      <channel>
      <title><![CDATA[*** variable text ***]]></title>
      <playlist_url><![CDATA[http://host.net/aa/vodpr/con_tv_r.php]]></playlist_url>
      <protected>True</protected>
      </channel>

      </items>









      share|improve this question














      I using this command for below xml file.



      xmlstarlet sel -t -v '//channel[protected = "True"]/playlist_url' -nl file.xml


      and result;



      host.net/aa/vodpr
      host.net/aa/vodpr/con_tv_r.php


      Can I choose a line in result? Example only last line or 2. line?



      <?xml version="1.0" encoding="UTF-8" ?>
      <items>

      <channel>
      <title><![CDATA[*** variable text ***]]></title>
      <playlist_url><![CDATA[http://host.net/aa/15_info/]]></playlist_url>
      </channel>

      <channel>
      <title><![CDATA[*** variable text ***]]></title>
      <playlist_url><![CDATA[http://host.net/aa/16_info/]]></playlist_url>
      </channel>

      <channel>
      <title><![CDATA[*** variable text ***]]></title>
      <playlist_url><![CDATA[http://host.net/aa/vodpr/]]></playlist_url>
      <protected>True</protected>
      </channel>

      <channel>
      <title><![CDATA[*** variable text ***]]></title>
      <playlist_url><![CDATA[http://host.net/aa/vodpr/con_tv_r.php]]></playlist_url>
      <protected>True</protected>
      </channel>

      </items>






      xml xmlstarlet






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 27 at 10:17









      Ali Haydar DoğanAli Haydar Doğan

      62




      62




















          1 Answer
          1






          active

          oldest

          votes


















          1














          To select the playlist_url value from the channel node by position in the list, use position() and compare with some positive integer:



          $ xmlstarlet sel -t -v '//channel[position() = 4]/playlist_url' -nl file.xml
          http://host.net/aa/vodpr/con_tv_r.php


          (in this case, you could use just [4] in place of [position() = 4]).



          $ xmlstarlet sel -t -v '//channel[position() > 2]/playlist_url' -nl file.xml
          http://host.net/aa/vodpr/
          http://host.net/aa/vodpr/con_tv_r.php


          To get the last two from a list of unknown length, combine the test with last():



          $ xmlstarlet sel -t -v '//channel[position() >= last() - 1]/playlist_url' -nl file.xml
          http://host.net/aa/vodpr/
          http://host.net/aa/vodpr/con_tv_r.php


          To get the second "protected" URL:



          $ xmlstarlet sel -t -v '//channel[protected = "True"][2]/playlist_url' -nl file.xml
          http://host.net/aa/vodpr/con_tv_r.php





          share|improve this answer























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f508934%2fextract-select-match-value-of-same-contents-in-xml-file%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            To select the playlist_url value from the channel node by position in the list, use position() and compare with some positive integer:



            $ xmlstarlet sel -t -v '//channel[position() = 4]/playlist_url' -nl file.xml
            http://host.net/aa/vodpr/con_tv_r.php


            (in this case, you could use just [4] in place of [position() = 4]).



            $ xmlstarlet sel -t -v '//channel[position() > 2]/playlist_url' -nl file.xml
            http://host.net/aa/vodpr/
            http://host.net/aa/vodpr/con_tv_r.php


            To get the last two from a list of unknown length, combine the test with last():



            $ xmlstarlet sel -t -v '//channel[position() >= last() - 1]/playlist_url' -nl file.xml
            http://host.net/aa/vodpr/
            http://host.net/aa/vodpr/con_tv_r.php


            To get the second "protected" URL:



            $ xmlstarlet sel -t -v '//channel[protected = "True"][2]/playlist_url' -nl file.xml
            http://host.net/aa/vodpr/con_tv_r.php





            share|improve this answer



























              1














              To select the playlist_url value from the channel node by position in the list, use position() and compare with some positive integer:



              $ xmlstarlet sel -t -v '//channel[position() = 4]/playlist_url' -nl file.xml
              http://host.net/aa/vodpr/con_tv_r.php


              (in this case, you could use just [4] in place of [position() = 4]).



              $ xmlstarlet sel -t -v '//channel[position() > 2]/playlist_url' -nl file.xml
              http://host.net/aa/vodpr/
              http://host.net/aa/vodpr/con_tv_r.php


              To get the last two from a list of unknown length, combine the test with last():



              $ xmlstarlet sel -t -v '//channel[position() >= last() - 1]/playlist_url' -nl file.xml
              http://host.net/aa/vodpr/
              http://host.net/aa/vodpr/con_tv_r.php


              To get the second "protected" URL:



              $ xmlstarlet sel -t -v '//channel[protected = "True"][2]/playlist_url' -nl file.xml
              http://host.net/aa/vodpr/con_tv_r.php





              share|improve this answer

























                1












                1








                1







                To select the playlist_url value from the channel node by position in the list, use position() and compare with some positive integer:



                $ xmlstarlet sel -t -v '//channel[position() = 4]/playlist_url' -nl file.xml
                http://host.net/aa/vodpr/con_tv_r.php


                (in this case, you could use just [4] in place of [position() = 4]).



                $ xmlstarlet sel -t -v '//channel[position() > 2]/playlist_url' -nl file.xml
                http://host.net/aa/vodpr/
                http://host.net/aa/vodpr/con_tv_r.php


                To get the last two from a list of unknown length, combine the test with last():



                $ xmlstarlet sel -t -v '//channel[position() >= last() - 1]/playlist_url' -nl file.xml
                http://host.net/aa/vodpr/
                http://host.net/aa/vodpr/con_tv_r.php


                To get the second "protected" URL:



                $ xmlstarlet sel -t -v '//channel[protected = "True"][2]/playlist_url' -nl file.xml
                http://host.net/aa/vodpr/con_tv_r.php





                share|improve this answer













                To select the playlist_url value from the channel node by position in the list, use position() and compare with some positive integer:



                $ xmlstarlet sel -t -v '//channel[position() = 4]/playlist_url' -nl file.xml
                http://host.net/aa/vodpr/con_tv_r.php


                (in this case, you could use just [4] in place of [position() = 4]).



                $ xmlstarlet sel -t -v '//channel[position() > 2]/playlist_url' -nl file.xml
                http://host.net/aa/vodpr/
                http://host.net/aa/vodpr/con_tv_r.php


                To get the last two from a list of unknown length, combine the test with last():



                $ xmlstarlet sel -t -v '//channel[position() >= last() - 1]/playlist_url' -nl file.xml
                http://host.net/aa/vodpr/
                http://host.net/aa/vodpr/con_tv_r.php


                To get the second "protected" URL:



                $ xmlstarlet sel -t -v '//channel[protected = "True"][2]/playlist_url' -nl file.xml
                http://host.net/aa/vodpr/con_tv_r.php






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 27 at 10:25









                KusalanandaKusalananda

                140k17261433




                140k17261433



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Unix & Linux Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f508934%2fextract-select-match-value-of-same-contents-in-xml-file%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    -xml, xmlstarlet

                    Popular posts from this blog

                    Frič See also Navigation menuinternal link

                    Identify plant with long narrow paired leaves and reddish stems Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?What is this plant with long sharp leaves? Is it a weed?What is this 3ft high, stalky plant, with mid sized narrow leaves?What is this young shrub with opposite ovate, crenate leaves and reddish stems?What is this plant with large broad serrated leaves?Identify this upright branching weed with long leaves and reddish stemsPlease help me identify this bulbous plant with long, broad leaves and white flowersWhat is this small annual with narrow gray/green leaves and rust colored daisy-type flowers?What is this chilli plant?Does anyone know what type of chilli plant this is?Help identify this plant

                    fontconfig warning: “/etc/fonts/fonts.conf”, line 100: unknown “element blank” The 2019 Stack Overflow Developer Survey Results Are In“tar: unrecognized option --warning” during 'apt-get install'How to fix Fontconfig errorHow do I figure out which font file is chosen for a system generic font alias?Why are some apt-get-installed fonts being ignored by fc-list, xfontsel, etc?Reload settings in /etc/fonts/conf.dTaking 30 seconds longer to boot after upgrade from jessie to stretchHow to match multiple font names with a single <match> element?Adding a custom font to fontconfigRemoving fonts from fontconfig <match> resultsBroken fonts after upgrading Firefox ESR to latest Firefox