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. (Xml) Reading a Selected Node Attributes [modified]

(Xml) Reading a Selected Node Attributes [modified]

Scheduled Pinned Locked Moved C#
xmlhelptutorial
1 Posts 1 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.
  • X Offline
    X Offline
    xEvOx
    wrote on last edited by
    #1

    right usually when i read Xml I do it like this :

    XmlDocument XmlDoc = new XmloDocument();
    XmlDoc.Load("C:\\Example.xml");
    XmlNodeList XmlnodeyList = XmlDoc.SelectNodes("Xml/Node");
    foreach(XmlNode Nodey in XmlNodeyList)
    {
    listView1.Items.Add((string.format("{0}", Nodey.Attributes["ExampleNode"].Value.ToString())));
    }

    Now that then populates a listview with the nodes in the xml file, I now have been pulling my hair out trying get it to red the second area of the nodes for example in the xml file :

    Sorry CodeProject Wouldent display it properally :)

    i want it to read the SecondNode but since i have say 4 of them all diffrent i want it to then read it and make a label have the secondnode text from the listview selected item , Here is the code i wrote for it :

    string Name = listView1.SelectedItems[0].ToString();
    XmlDocument XmlDoc = new XmlDocument();
    XmlDoc.Load(XmlPath);
    XmlNode Nodey = XmlDoc.SelectSingleNode(string.Format("Xml/Node/{0}", Name));
    label1.Text = (string.Format("{0}", Nodey.Attributes["SecondNode"].Value.ToString()));

    so on click from the listview it gets the second node etc , any help wouyld be grand guys ! Jed

    modified on Saturday, April 3, 2010 5:11 AM

    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