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. How to select xmls nodes based on multiple filter criteria

How to select xmls nodes based on multiple filter criteria

Scheduled Pinned Locked Moved C#
csharpxmltutorial
5 Posts 4 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.
  • H Offline
    H Offline
    Harkamal Singh
    wrote on last edited by
    #1

    Sample XML ---------- C# Code (FAILS) --------------- XmlNodeList nodes = xml.SelectNodes(@"/Licenses/License[@HostName='host1'] and [@IPAddress='192.168.1.2' ]"); XmlNode node = xml.SelectSinglenode(@"/Licenses/License[@HostName='SIN520APP190'] and [@IPAddress='192.168.1.2' ]"); Basically I need to know how to select node(s) by applying filters on 2 or more attributes. It works with single attribute though. Thanks. h

    P R S 3 Replies Last reply
    0
    • H Harkamal Singh

      Sample XML ---------- C# Code (FAILS) --------------- XmlNodeList nodes = xml.SelectNodes(@"/Licenses/License[@HostName='host1'] and [@IPAddress='192.168.1.2' ]"); XmlNode node = xml.SelectSinglenode(@"/Licenses/License[@HostName='SIN520APP190'] and [@IPAddress='192.168.1.2' ]"); Basically I need to know how to select node(s) by applying filters on 2 or more attributes. It works with single attribute though. Thanks. h

      P Offline
      P Offline
      pmarfleet
      wrote on last edited by
      #2

      what error do you get?

      1 Reply Last reply
      0
      • H Harkamal Singh

        Sample XML ---------- C# Code (FAILS) --------------- XmlNodeList nodes = xml.SelectNodes(@"/Licenses/License[@HostName='host1'] and [@IPAddress='192.168.1.2' ]"); XmlNode node = xml.SelectSinglenode(@"/Licenses/License[@HostName='SIN520APP190'] and [@IPAddress='192.168.1.2' ]"); Basically I need to know how to select node(s) by applying filters on 2 or more attributes. It works with single attribute though. Thanks. h

        R Offline
        R Offline
        Rocky
        wrote on last edited by
        #3

        XmlNode node = xml.SelectSinglenode(@"/Licenses/License[@HostName='SIN520APP190' and @IPAddress='192.168.1.2'] "); try this out and c what happens Rocky

        H 1 Reply Last reply
        0
        • H Harkamal Singh

          Sample XML ---------- C# Code (FAILS) --------------- XmlNodeList nodes = xml.SelectNodes(@"/Licenses/License[@HostName='host1'] and [@IPAddress='192.168.1.2' ]"); XmlNode node = xml.SelectSinglenode(@"/Licenses/License[@HostName='SIN520APP190'] and [@IPAddress='192.168.1.2' ]"); Basically I need to know how to select node(s) by applying filters on 2 or more attributes. It works with single attribute though. Thanks. h

          S Offline
          S Offline
          sathish s
          wrote on last edited by
          #4

          Specifying Boolean Operators in XPath Queries[^] Hope this helps

          1 Reply Last reply
          0
          • R Rocky

            XmlNode node = xml.SelectSinglenode(@"/Licenses/License[@HostName='SIN520APP190' and @IPAddress='192.168.1.2'] "); try this out and c what happens Rocky

            H Offline
            H Offline
            Harkamal Singh
            wrote on last edited by
            #5

            Thanks Rocky.. xml.SelectSingleNode(@"/Licenses/License[@Att1='xx' and @Att2='xx'] works. Problem was with my syntax, i was enclosing each attribute within square braces. God bless.

            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