Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. Xpath expression

Xpath expression

Scheduled Pinned Locked Moved XML / XSL
xmlcsharphelpquestion
8 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Ibana
    wrote on last edited by
    #1

    Hi, Im quite new to xpath in .Net. I have an XML-structure shown below that contain measurements(diameters,areas etc) The one below includes two different measurements of an Bi diameter and also the mean value. I now want to extract the mean value.(the 5.0 tag. As mentioned ,the file consists of many different measurements using the same strucutre. With the following expression I manage to extract the value but then I also get all the following mean values from all of the other calculations. How do I extract ONLY that node. I would really appriciate some help thanks! Expression: //item/item/concept[@codValue='11820-8']/following-sibling::item/value[@codValue='R-00317']/following::value MeasureGroup Bi Diameter 4.9 Bi Diameter 5.1 Bi Diameter Mean 5.0

    G 1 Reply Last reply
    0
    • I Ibana

      Hi, Im quite new to xpath in .Net. I have an XML-structure shown below that contain measurements(diameters,areas etc) The one below includes two different measurements of an Bi diameter and also the mean value. I now want to extract the mean value.(the 5.0 tag. As mentioned ,the file consists of many different measurements using the same strucutre. With the following expression I manage to extract the value but then I also get all the following mean values from all of the other calculations. How do I extract ONLY that node. I would really appriciate some help thanks! Expression: //item/item/concept[@codValue='11820-8']/following-sibling::item/value[@codValue='R-00317']/following::value MeasureGroup Bi Diameter 4.9 Bi Diameter 5.1 Bi Diameter Mean 5.0

      G Offline
      G Offline
      George L Jackson
      wrote on last edited by
      #2

      I hope this works: /item/item[item/value[@codValue='R-00317']]/value or /item/item[item/value='Mean']/value

      "We make a living by what we get, we make a life by what we give." --Winston Churchill

      I 2 Replies Last reply
      0
      • G George L Jackson

        I hope this works: /item/item[item/value[@codValue='R-00317']]/value or /item/item[item/value='Mean']/value

        "We make a living by what we get, we make a life by what we give." --Winston Churchill

        I Offline
        I Offline
        Ibana
        wrote on last edited by
        #3

        Hi, Thanks alot for your help I have been away a while but It I have tried your suggestion below and it extracts the mean value. /item/item[item/value[@codValue='R-00317']]/value I still have a small problem though. With your suggestion I also extract the other measurements mean value (see example below) I have tried to “tune” my search using your example, but I don’t get the hang of it, I need to somehow check two different attributes both and instead of just one as before. Is it possible to do that in one expression? Example code.. MeasureGroup Bi Diameter 4.9 Bi Diameter 5.1 Bi Diameter Mean 5.0 MeasureGroup ADH length 2.2 ADH length 2.4 ADH length Mean 2.3

        1 Reply Last reply
        0
        • G George L Jackson

          I hope this works: /item/item[item/value[@codValue='R-00317']]/value or /item/item[item/value='Mean']/value

          "We make a living by what we get, we make a life by what we give." --Winston Churchill

          I Offline
          I Offline
          Ibana
          wrote on last edited by
          #4

          oopps. I forgot to ignore html..Example code.. MeasureGroup Bi Diameter 4.9 Bi Diameter 5.1 Bi Diameter Mean 5.0 MeasureGroup ADH length 2.2 ADH length 2.4 ADH length Mean 2.3

          G 1 Reply Last reply
          0
          • I Ibana

            oopps. I forgot to ignore html..Example code.. MeasureGroup Bi Diameter 4.9 Bi Diameter 5.1 Bi Diameter Mean 5.0 MeasureGroup ADH length 2.2 ADH length 2.4 ADH length Mean 2.3

            G Offline
            G Offline
            George L Jackson
            wrote on last edited by
            #5

            Which attribute did you want to add to the query?

            "We make a living by what we get, we make a life by what we give." --Winston Churchill

            I 1 Reply Last reply
            0
            • G George L Jackson

              Which attribute did you want to add to the query?

              "We make a living by what we get, we make a life by what we give." --Winston Churchill

              I Offline
              I Offline
              Ibana
              wrote on last edited by
              #6

              I would like to add the codValue attribut from the concept node. Bi Diameter

              G 1 Reply Last reply
              0
              • I Ibana

                I would like to add the codValue attribut from the concept node. Bi Diameter

                G Offline
                G Offline
                George L Jackson
                wrote on last edited by
                #7

                /item/item[concept[@codValue='11820-8'] and item/value[@codValue='R-00317']]/value The concept element, the third level item element(with the value child element) and second level value element (target of the query) are all siblings and children of the second level item element. George

                "We make a living by what we get, we make a life by what we give." --Winston Churchill

                I 1 Reply Last reply
                0
                • G George L Jackson

                  /item/item[concept[@codValue='11820-8'] and item/value[@codValue='R-00317']]/value The concept element, the third level item element(with the value child element) and second level value element (target of the query) are all siblings and children of the second level item element. George

                  "We make a living by what we get, we make a life by what we give." --Winston Churchill

                  I Offline
                  I Offline
                  Ibana
                  wrote on last edited by
                  #8

                  Hi it was the and operator that I was looking for, didn't knew that you could combine multiple conditions. Thanks for your help! :-D

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups