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. hi,plz help (how can i access to xml node)

hi,plz help (how can i access to xml node)

Scheduled Pinned Locked Moved C#
csharpdebuggingxmlhelptutorial
5 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.
  • P Offline
    P Offline
    premkamalg
    wrote on last edited by
    #1

    i new to c#.net i want to access one node in xmlfile using c#.net . that node have child node (i want that child node values) i write my xml file like this < < <Ap <MP <UP < <gjsefgjkl<dfhtyxcvd<ioiopweri < in this i want to access the "add" child node value. i wrote c#.net code like this, "When i press Button the childnode("add") values r stored in listbox " plz change any modification in my code or plz give code how to access thatnode private void button1_Click(object sender, System.EventArgs e) { string filename = "C:\\C#program\\cs_programs\\singlenode\\bin\\Debug\\nodexml.xml"; XmlTextReader tr = new XmlTextReader(filename); XmlDocument doc = new XmlDocument(); while(tr.Read()) { foreach(XmlNode node in doc.SelectNodes("//details/add/addr")) listBox1.Items.Add(tr.Value); } } Thanks

    C 1 Reply Last reply
    0
    • P premkamalg

      i new to c#.net i want to access one node in xmlfile using c#.net . that node have child node (i want that child node values) i write my xml file like this < < <Ap <MP <UP < <gjsefgjkl<dfhtyxcvd<ioiopweri < in this i want to access the "add" child node value. i wrote c#.net code like this, "When i press Button the childnode("add") values r stored in listbox " plz change any modification in my code or plz give code how to access thatnode private void button1_Click(object sender, System.EventArgs e) { string filename = "C:\\C#program\\cs_programs\\singlenode\\bin\\Debug\\nodexml.xml"; XmlTextReader tr = new XmlTextReader(filename); XmlDocument doc = new XmlDocument(); while(tr.Read()) { foreach(XmlNode node in doc.SelectNodes("//details/add/addr")) listBox1.Items.Add(tr.Value); } } Thanks

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      I've answered this, please stop asking these questions and instead go and read any basic XPath tutorial.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

      P 1 Reply Last reply
      0
      • C Christian Graus

        I've answered this, please stop asking these questions and instead go and read any basic XPath tutorial.

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

        P Offline
        P Offline
        premkamalg
        wrote on last edited by
        #3

        hi thanks for answered, i try u r solution. but my cod eis not working plz check my code , let me know any thing wrong in my code. Plz help Thanks

        Hi, Thanks, if u think it's good. otherwise sorry.

        C 1 Reply Last reply
        0
        • P premkamalg

          hi thanks for answered, i try u r solution. but my cod eis not working plz check my code , let me know any thing wrong in my code. Plz help Thanks

          Hi, Thanks, if u think it's good. otherwise sorry.

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          foreach(XmlNode node in doc.SelectNodes("//details/add/addr")) Well, to be honest, I see no sign that you've done anything I've told you to do, to date. Your nodes are still named addr1, addr2 and addr3, which means the above XPath will never return anything. If you want the add node, then you want to use SelectSingleNode, and if you can't work out that to select the add node you need //details/add, then there's a serious problem here.

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

          P 1 Reply Last reply
          0
          • C Christian Graus

            foreach(XmlNode node in doc.SelectNodes("//details/add/addr")) Well, to be honest, I see no sign that you've done anything I've told you to do, to date. Your nodes are still named addr1, addr2 and addr3, which means the above XPath will never return anything. If you want the add node, then you want to use SelectSingleNode, and if you can't work out that to select the add node you need //details/add, then there's a serious problem here.

            Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

            P Offline
            P Offline
            premkamalg
            wrote on last edited by
            #5

            Thanks

            Hi, Thanks, if u think it's good. otherwise sorry.

            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