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

                    Creating 100m^2 grid automatically using QGIS?Creating grid constrained within polygon in QGIS?Createing polygon layer from point data using QGIS?Creating vector grid using QGIS?Creating grid polygons from coordinates using R or PythonCreating grid from spatio temporal point data?Creating fields in attributes table using other layers using QGISCreate .shp vector grid in QGISQGIS Creating 4km point grid within polygonsCreate a vector grid over a raster layerVector Grid Creates just one grid

                    Nikolai Prilezhaev Bibliography References External links Navigation menuEarly Russian Organic Chemists and Their Legacy092774english translationRussian Biography

                    How to link a C library to an Assembly library on Mac with clangHow do you set, clear, and toggle a single bit?Find (and kill) process locking port 3000 on MacWho is listening on a given TCP port on Mac OS X?How to start PostgreSQL server on Mac OS X?Compile assembler in nasm on mac osHow do I install pip on macOS or OS X?AFNetworking 2.0 “_NSURLSessionTransferSizeUnknown” linking error on Mac OS X 10.8C++ code for testing the Collatz conjecture faster than hand-written assembly - why?How to link a NASM code and GCC in Mac OS X?How to run x86 .asm on macOS Sierra