locked
Listview with XML RRS feed

  • Question

  • Hello

             I am writing a server application. which shows the status(alive or dead) of different application running on different server.

     

    I use listview to show images if any image of the server1 (compountent) is black and white  color then it mean server is dead. if color full image server is alive.

     

     

    i have create following XML to load on Listview

     

     <Server>

        <Groups>

          <Group id="1">

               <Nodes>

                    <Node id="1">

                      <CompontantID>TE.TE-REGCO.01.01.</CompontantID>

                      <IP>172.16.32.1</IP>

                      <Port>6000</Port>

                      <ImageIndex>ImageName</ImageIndex>

                      <ToolTip>Connected</ToolTip>

            </Node>

                    <Node id="2">

                      <CompontantID>TE.TE-REGCO.01.01.</CompontantID>

                      <IP>172.16.32.1</IP>

                      <Port>6000</Port>

                      <ImageIndex>ImageName</ImageIndex>

                      <ToolTip>Connected</ToolTip>

            </Node>

            </Nodes>

          </Group>  

     

          <Group id="2">

              <Nodes>

                   <Node id="1">

                      <CompontantID>TE.TE-REGCO.01.01.</CompontantID>

                      <IP>172.16.32.1</IP>

                      <Port>6000</Port>

                      <ImageIndex>ImageName</ImageIndex>

                      <ToolTip>Connected</ToolTip>

            </Node>

                   <Node id="2">

                      <CompontantID>TE.TE-REGCO.01.01.</CompontantID>

                      <IP>172.16.32.1</IP>

                      <Port>6000</Port>

                      <ImageIndex>ImageName</ImageIndex>

                      <ToolTip>Connected</ToolTip>

            </Node>

            </Nodes>

          </Group>

     

        </Groups>

      </Server>

     

     

    HOW CAN I LOAD THE ABOVE XML TO LISTVIEW WITH ONE IMAGE OF EACH NODE.

     

    REGARDS


    It's Me
    Wednesday, May 18, 2011 11:09 AM

Answers

  •       XmlDocument doc = new XmlDocument();
          doc.Load("../../Server.xml");
    
          XmlNodeList nodes = doc.GetElementsByTagName("Node");
    
          foreach (XmlNode node in nodes)
          {
            foreach (XmlNode childNode in node.ChildNodes)
            {
              if (childNode.Name == "ImageIndex")
                listView1.Items.Add(childNode.InnerText);
            }
          }
    


    Leo Liu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by It_s Meee Monday, May 23, 2011 1:23 PM
    Friday, May 20, 2011 4:38 AM