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. Web Development
  3. ASP.NET
  4. XML Problem

XML Problem

Scheduled Pinned Locked Moved ASP.NET
helpxml
3 Posts 3 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.
  • I Offline
    I Offline
    InderK
    wrote on last edited by
    #1

    Hi All, Please help me regarding a doubt. i have a .xml file which is having around 3000 nodes, now I want to retrieve the name attribute of those nodes for which store attribute>30. Please suggest the esaiest way to do it. Thanks, Inder....

    T N 2 Replies Last reply
    0
    • I InderK

      Hi All, Please help me regarding a doubt. i have a .xml file which is having around 3000 nodes, now I want to retrieve the name attribute of those nodes for which store attribute>30. Please suggest the esaiest way to do it. Thanks, Inder....

      T Offline
      T Offline
      torken2
      wrote on last edited by
      #2

      Load the xml with the XmlDocument and use xpath to get the nodes. Iterate those nodes the read the attribute. Example:

                  XmlDocument xmlDoc = new XmlDocument();
                  xmlDoc.Load("XMLFile.xml");
                  XmlNodeList selectedNodes =  xmlDoc.SelectNodes("//Store[@Stores>30]");
      
                  foreach (XmlNode item in selectedNodes)
                  {
                      Console.WriteLine(item.Attributes["name"].Value);
                  }
      
                  Console.ReadLine();
      

      My xml file:

      <?xml version="1.0" encoding="utf-8" ?>
      <Stores>
      <Store name="Name1" store="10"/>
      <Store name="Name2" store="20"/>
      <Store name="Name3" store="30"/>
      <Store name="Name4" store="40"/>
      </Stores>

      1 Reply Last reply
      0
      • I InderK

        Hi All, Please help me regarding a doubt. i have a .xml file which is having around 3000 nodes, now I want to retrieve the name attribute of those nodes for which store attribute>30. Please suggest the esaiest way to do it. Thanks, Inder....

        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #3

        Don't cross post!:mad: You have already asked this question in the C# forum, which is more appropriate than the ASP.NET forum but should have been placed in the XML forum


        I know the language. I've read a book. - _Madmatt

        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