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. C#
  4. Searching XML file

Searching XML file

Scheduled Pinned Locked Moved C#
xmltutorialalgorithmsbusinessannouncement
4 Posts 3 Posters 1 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.
  • N Offline
    N Offline
    NarVish
    wrote on last edited by
    #1

    Hi, I would like to get "Token" value based on the description from the below xml file. For example, if my input is 'Company'(Description), it should return 'COS'(Token). I tried with XPath. But not working due to multi level of nodes in xml. Could you pls guide me to achieve this. Thanks in advance.

    PROD
    prod
    BUSINESS
      Business News
      COS
        Company News
        ANA
          Analyst Ratings
          ANAMOVES
            Analyst Ratings, Estimates and Target Price Changes
            ANACHANGE
              Analyst Rating Changes
              ANACUT
                Analyst Downgrades
                ANACUTEVT
                  Analyst Ratings Cut Events, Announcements
                
              
            
          
          IP
            Intellectual Property
            COPYRIGHT
              Copyrights
            
          
        
      
      DRGPATENT
        Drug Patents
    
    M N 2 Replies Last reply
    0
    • N NarVish

      Hi, I would like to get "Token" value based on the description from the below xml file. For example, if my input is 'Company'(Description), it should return 'COS'(Token). I tried with XPath. But not working due to multi level of nodes in xml. Could you pls guide me to achieve this. Thanks in advance.

      PROD
      prod
      BUSINESS
        Business News
        COS
          Company News
          ANA
            Analyst Ratings
            ANAMOVES
              Analyst Ratings, Estimates and Target Price Changes
              ANACHANGE
                Analyst Rating Changes
                ANACUT
                  Analyst Downgrades
                  ANACUTEVT
                    Analyst Ratings Cut Events, Announcements
                  
                
              
            
            IP
              Intellectual Property
              COPYRIGHT
                Copyrights
              
            
          
        
        DRGPATENT
          Drug Patents
      
      M Offline
      M Offline
      Mirko1980
      wrote on last edited by
      #2

      Use // to search in any level into your XML. The following XPath will give you what you want: //Entity[contains(./Description, 'Company')]/Token

      N 1 Reply Last reply
      0
      • N NarVish

        Hi, I would like to get "Token" value based on the description from the below xml file. For example, if my input is 'Company'(Description), it should return 'COS'(Token). I tried with XPath. But not working due to multi level of nodes in xml. Could you pls guide me to achieve this. Thanks in advance.

        PROD
        prod
        BUSINESS
          Business News
          COS
            Company News
            ANA
              Analyst Ratings
              ANAMOVES
                Analyst Ratings, Estimates and Target Price Changes
                ANACHANGE
                  Analyst Rating Changes
                  ANACUT
                    Analyst Downgrades
                    ANACUTEVT
                      Analyst Ratings Cut Events, Announcements
                    
                  
                
              
              IP
                Intellectual Property
                COPYRIGHT
                  Copyrights
                
              
            
          
          DRGPATENT
            Drug Patents
        
        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #3

        You could use Linq to XML[^]


        I know the language. I've read a book. - _Madmatt

        1 Reply Last reply
        0
        • M Mirko1980

          Use // to search in any level into your XML. The following XPath will give you what you want: //Entity[contains(./Description, 'Company')]/Token

          N Offline
          N Offline
          NarVish
          wrote on last edited by
          #4

          Thank you Mirko1980, its working

          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