Get the values of child tags based on the value of another child tag











up vote
0
down vote

favorite












Assuming that I have a LONGTEXT column in MySQL that contains the following value



<Parent1> 
<Parent2>
<Parent3>
<id>1</id>
<name>Testing 1</name>
<age>10</age>
</Parent3>

<Parent3>
<id>2</id>
<name>Testing 2</name>
<age>5</age>
</Parent3>
</Parent2>
</Parent1>


I want to extract the values for child tags name and age where the id of Parent3 is equal to 2 but I am not quite sure what xpath should I pass to extractValue in order to achieve this.



Any guidance would be much appreciated.










share|improve this question




























    up vote
    0
    down vote

    favorite












    Assuming that I have a LONGTEXT column in MySQL that contains the following value



    <Parent1> 
    <Parent2>
    <Parent3>
    <id>1</id>
    <name>Testing 1</name>
    <age>10</age>
    </Parent3>

    <Parent3>
    <id>2</id>
    <name>Testing 2</name>
    <age>5</age>
    </Parent3>
    </Parent2>
    </Parent1>


    I want to extract the values for child tags name and age where the id of Parent3 is equal to 2 but I am not quite sure what xpath should I pass to extractValue in order to achieve this.



    Any guidance would be much appreciated.










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Assuming that I have a LONGTEXT column in MySQL that contains the following value



      <Parent1> 
      <Parent2>
      <Parent3>
      <id>1</id>
      <name>Testing 1</name>
      <age>10</age>
      </Parent3>

      <Parent3>
      <id>2</id>
      <name>Testing 2</name>
      <age>5</age>
      </Parent3>
      </Parent2>
      </Parent1>


      I want to extract the values for child tags name and age where the id of Parent3 is equal to 2 but I am not quite sure what xpath should I pass to extractValue in order to achieve this.



      Any guidance would be much appreciated.










      share|improve this question















      Assuming that I have a LONGTEXT column in MySQL that contains the following value



      <Parent1> 
      <Parent2>
      <Parent3>
      <id>1</id>
      <name>Testing 1</name>
      <age>10</age>
      </Parent3>

      <Parent3>
      <id>2</id>
      <name>Testing 2</name>
      <age>5</age>
      </Parent3>
      </Parent2>
      </Parent1>


      I want to extract the values for child tags name and age where the id of Parent3 is equal to 2 but I am not quite sure what xpath should I pass to extractValue in order to achieve this.



      Any guidance would be much appreciated.







      mysql xml xpath






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 19 at 15:30

























      asked Nov 19 at 15:03









      Giorgos Myrianthous

      3,63121233




      3,63121233
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          You can use



          //Parent3[id=2]/name/text()
          //Parent3[id=2]/age/text()


          To extract values of name and age children of Parent3 that contain id equal to 2






          share|improve this answer




























            up vote
            1
            down vote













            If you want one xpath to get the results I see 2 ways of doing this



            1 :



            //Parent3[id = 2]/name/text()|//Parent3[id = 2]/age/text()


            2 :



            //Parent3[id = 2]/*[self::name|self::age]/text()





            share|improve this answer





















              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              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',
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              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%2fstackoverflow.com%2fquestions%2f53377385%2fget-the-values-of-child-tags-based-on-the-value-of-another-child-tag%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              1
              down vote



              accepted










              You can use



              //Parent3[id=2]/name/text()
              //Parent3[id=2]/age/text()


              To extract values of name and age children of Parent3 that contain id equal to 2






              share|improve this answer

























                up vote
                1
                down vote



                accepted










                You can use



                //Parent3[id=2]/name/text()
                //Parent3[id=2]/age/text()


                To extract values of name and age children of Parent3 that contain id equal to 2






                share|improve this answer























                  up vote
                  1
                  down vote



                  accepted







                  up vote
                  1
                  down vote



                  accepted






                  You can use



                  //Parent3[id=2]/name/text()
                  //Parent3[id=2]/age/text()


                  To extract values of name and age children of Parent3 that contain id equal to 2






                  share|improve this answer












                  You can use



                  //Parent3[id=2]/name/text()
                  //Parent3[id=2]/age/text()


                  To extract values of name and age children of Parent3 that contain id equal to 2







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 19 at 15:17









                  Andersson

                  35.2k103066




                  35.2k103066
























                      up vote
                      1
                      down vote













                      If you want one xpath to get the results I see 2 ways of doing this



                      1 :



                      //Parent3[id = 2]/name/text()|//Parent3[id = 2]/age/text()


                      2 :



                      //Parent3[id = 2]/*[self::name|self::age]/text()





                      share|improve this answer

























                        up vote
                        1
                        down vote













                        If you want one xpath to get the results I see 2 ways of doing this



                        1 :



                        //Parent3[id = 2]/name/text()|//Parent3[id = 2]/age/text()


                        2 :



                        //Parent3[id = 2]/*[self::name|self::age]/text()





                        share|improve this answer























                          up vote
                          1
                          down vote










                          up vote
                          1
                          down vote









                          If you want one xpath to get the results I see 2 ways of doing this



                          1 :



                          //Parent3[id = 2]/name/text()|//Parent3[id = 2]/age/text()


                          2 :



                          //Parent3[id = 2]/*[self::name|self::age]/text()





                          share|improve this answer












                          If you want one xpath to get the results I see 2 ways of doing this



                          1 :



                          //Parent3[id = 2]/name/text()|//Parent3[id = 2]/age/text()


                          2 :



                          //Parent3[id = 2]/*[self::name|self::age]/text()






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 19 at 15:23









                          Nesku

                          19519




                          19519






























                               

                              draft saved


                              draft discarded



















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53377385%2fget-the-values-of-child-tags-based-on-the-value-of-another-child-tag%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

                              404 Error Contact Form 7 ajax form submitting

                              How to know if a Active Directory user can login interactively

                              TypeError: fit_transform() missing 1 required positional argument: 'X'