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. Selecting a particular element

Selecting a particular element

Scheduled Pinned Locked Moved XML / XSL
xmlhelptutorialquestion
3 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.
  • K Offline
    K Offline
    kumarjammula
    wrote on last edited by
    #1

    <USA> <State> <Name>Alabama</Name> <Counties> <1>Autauga <2>Baldwin <3>Barbour </Counties> </State> <State> <Name>Alaska</Name> <1>Aleutians East <2>Aleutians West <3>Anchorage Friends this my Xml file I had attached all States names to DropdownList And My problem is when particular state is selected in Dropdown list how can I retrive Counties to a particular state plse suggest me an example

    came out of hardwork

    G 1 Reply Last reply
    0
    • K kumarjammula

      <USA> <State> <Name>Alabama</Name> <Counties> <1>Autauga <2>Baldwin <3>Barbour </Counties> </State> <State> <Name>Alaska</Name> <1>Aleutians East <2>Aleutians West <3>Anchorage Friends this my Xml file I had attached all States names to DropdownList And My problem is when particular state is selected in Dropdown list how can I retrive Counties to a particular state plse suggest me an example

      came out of hardwork

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

      The structure of your XML is flawed. It should look something like this:

      <usa>
      	<state name="Alabama">
      		<county name="Autauga"/>
      		<county name="Baldwin"/>
      		<county name="Barbour"/>
      	</state>
      	<state name="Alaska">
      		<county name="Aluetians East"/>
      		<county name="Aluetians West"/>
      		<county name="Anchorage"/>
      	</state>
      </usa>
      

      With this structure, when a state is choosen you can use the XPath:

      /usa/state[@name='Alaska']/county/@name
      

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

      K 1 Reply Last reply
      0
      • G George L Jackson

        The structure of your XML is flawed. It should look something like this:

        <usa>
        	<state name="Alabama">
        		<county name="Autauga"/>
        		<county name="Baldwin"/>
        		<county name="Barbour"/>
        	</state>
        	<state name="Alaska">
        		<county name="Aluetians East"/>
        		<county name="Aluetians West"/>
        		<county name="Anchorage"/>
        	</state>
        </usa>
        

        With this structure, when a state is choosen you can use the XPath:

        /usa/state[@name='Alaska']/county/@name
        

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

        K Offline
        K Offline
        kumarjammula
        wrote on last edited by
        #3

        Thak u for ur suggestion

        came out of hardwork

        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