Extract select match value of same contents in XML file The Next CEO of Stack OverflowText 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

How to start emacs in "nothing" mode (`fundamental-mode`)

How do I construct this japanese bowl?

How easy is it to start Magic from scratch?

I believe this to be a fraud - hired, then asked to cash check and send cash as Bitcoin

How should I support this large drywall patch?

How to count occurrences of text in a file?

How did people program for Consoles with multiple CPUs?

Describing a person. What needs to be mentioned?

The King's new dress

Would this house-rule that treats advantage as a +1 to the roll instead (and disadvantage as -1) and allows them to stack be balanced?

Science fiction (dystopian) short story set after WWIII

Can the Reverse Gravity spell affect the Meteor Swarm spell?

What is the purpose of the Evocation wizard's Potent Cantrip feature?

MAZDA 3 2006 (UK) - poor acceleration then takes off at 3250 revs

Is HostGator storing my password in plaintext?

Only print output after finding pattern

What makes a siege story/plot interesting?

How do spells that require an ability check vs. the caster's spell save DC work?

What is the difference between "behavior" and "behaviour"?

How long to clear the 'suck zone' of a turbofan after start is initiated?

Why here is plural "We went to the movies last night."

How to be diplomatic in refusing to write code that breaches the privacy of our users

Is it my responsibility to learn a new technology in my own time my employer wants to implement?

Text adventure game code



Extract select match value of same contents in XML file



The Next CEO of Stack OverflowText 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










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 yesterday









      Ali Haydar DoğanAli Haydar Doğan

      62




      62




















          1 Answer
          1






          active

          oldest

          votes


















          0














          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









            0














            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



























              0














              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

























                0












                0








                0







                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 yesterday









                KusalanandaKusalananda

                138k17258426




                138k17258426



























                    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







                    Popular posts from this blog

                    getting Checkpoint VPN SSL Network Extender working in the command lineHow to connect to CheckPoint VPN on Ubuntu 18.04LTS?Will the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayVPN SSL Network Extender in FirefoxLinux Checkpoint SNX tool configuration issuesCheck Point - Connect under Linux - snx + OTPSNX VPN Ububuntu 18.XXUsing Checkpoint VPN SSL Network Extender CLI with certificateVPN with network manager (nm-applet) is not workingWill the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayImport VPN config files to NetworkManager from command lineTrouble connecting to VPN using network-manager, while command line worksStart a VPN connection with PPTP protocol on command linestarting a docker service daemon breaks the vpn networkCan't connect to vpn with Network-managerVPN SSL Network Extender in FirefoxUsing Checkpoint VPN SSL Network Extender CLI with certificate

                    Cannot Extend partition with GParted The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election ResultsCan't increase partition size with GParted?GParted doesn't recognize the unallocated space after my current partitionWhat is the best way to add unallocated space located before to Ubuntu 12.04 partition with GParted live?I can't figure out how to extend my Arch home partition into free spaceGparted Linux Mint 18.1 issueTrying to extend but swap partition is showing as Unknown in Gparted, shows proper from fdiskRearrange partitions in gparted to extend a partitionUnable to extend partition even though unallocated space is next to it using GPartedAllocate free space to root partitiongparted: how to merge unallocated space with a partition

                    Marilyn Monroe Ny fiainany manokana | Jereo koa | Meny fitetezanafanitarana azy.